answersLogoWhite

0


Best Answer

string, vector and array do not have a common base class. Overload your function to accept either a string, a vector or an array.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What do string and vector and array all inherit from that has the size method so you can take it as an argument?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Rearrange the string in alphabetical order in two dimensional character array?

Use a std::vector<std::string>> to store the strings, then call the std::vector::sort() method.


How do you implement vector?

import java.util.Vector; public class VectorTest { /** * @param args */ public static void main(String[] args) { //instantiating a vector Vector vct = new Vector(); //Add objects to a vector vct.add("One"); //getting values from the vector String val = (String) vct.get(0); //vector size System.out.println("Vector size is: " + vct.size()); //removing elements from a vector vct.remove(0); } }


When drawing a vector using the triangle method of addition how do you draw in the resultant vector?

When drawing a vector using the triangle method you will draw in the resultant vector using Pythagorean theorem. This is taught in physics.


Can vector store string values in java programming?

A Vector can store any objects, so yes.


What is inventory displayer c plus plus?

// Inventory Displayer // Demonstrates constant references #include <iostream> #include <string> #include <vector> using namespace std; //parameter vec is a constant reference to a vector of strings void display(const vector<string>& vec); int main() { vector<string> inventory; inventory.push_back( "sword"); inventory.push_back( "armor"); inventory.push_back( "shield"); display(inventory); return 0; } //parameter vec is a constant reference to a vector of strings void display(const vector<string>& vec) { cout << "Your items:\n"; for (vector<string>::const_iterator iter = vec.begin(); iter != vec.end(); ++iter) { cout << *iter << endl; } }


How will you get the third vector if the 1st and 2nd vector was given and the resultant vector is equal to 0?

by method of finding resultant


When solving vector addition problem you can either the graphical method or the?

analytical method.


Where is the second vector's tail placed when two vectors are added graphically using the tip to tail method?

it is placed at the tip of the first vector


What is the vector sum of 7 and 5 and 13 and -5?

The whole point of a vector is that it has a magnitude and a direction. There are no directions given in the above string of numbers.


When solving a vector addition problems you can use either the graphical method or?

analytical method.


When solving vector addition problems you can use either the graphical method or the .?

analytical method.


How do you split a string in delimit c plus plus?

#include<iostream> #include<vector> #include<string> std::vector<std::string> parse (const std::string& s, const char delim) { std::vector<std::string> result {}; auto start = 0U; auto end = s.find (delim); while (end != s.npos) { result.push_back (s.substr(start, end - start)); start = ++end; end = s.find (delim, start); } result.push_back (s.substr (start, s.npos - start)); return result; } std::vector<std::string> parse (const std::string& s, const std::string& delim) { std::vector<std::string> result {}; auto start = 0U; auto end = s.find (delim); while (end != s.npos) { result.push_back (s.substr(start, end - start)); start = end + delim.length(); end = s.find (delim, start); } result.push_back (s.substr (start, s.npos - start)); return result; } int main() { std::string str1 = "This is a string that will be parsed by a single-space delimiter."; std::string str2 = "This==is==a==string==that==will==be==parsed==by==equal==operator."; std::string str3 = "This string has no delimiter."; std::cout << str1 << std::endl; std::vector<std::string> v1 = parse (str1, ' '); for (auto i : v1 ) std::cout << i << std::endl; std::cout << std::endl; std::cout << str2 << std::endl; std::vector<std::string> v2 = parse (str2, "=="); for (auto i : v2 ) std::cout << i << std::endl; std::cout << std::endl; std::cout << str3 << std::endl; std::vector<std::string> v3 = parse (str3, '\\'); for (auto i : v3 ) std::cout << i << std::endl; std::cout << std::endl; }