I have used a vector class inside a function like below to get every object in that class.
std::vector<ClassName>student_detail(size);
Now I want to pass this vector class into another function and access class objects in that function. However, I don't what type to use?! if I pass it like this->
void function(std::vector<ClassName>& name)
I get multiple errors:
Error C2923 'std::vector': 'ClassName' is not a valid template type argument for parameter '_Ty'
Line 11 of first excerpt: The compiler doesn't know what Person is at this point.
Forward declare class Person before class Sql
1 2 3 4 5
class Person;
class Sql : public mainClass {
// ...
};
PS: You should also be #including the necessary files, such as #include <vector> , #include <string?
PPS: If you have an empty constructor and destructor, it's a sign that you don't need to define these in the first place. See: "rule of 0". And even if you have custom logic in the constructor, you still only need a destructor if you need to clean up some non-RAII resources.
All good, the reason I brought up the #includes is that (in general) it might be important to show them when you are running into errors like "undeclared identifiers".