We are learning classes and I am doing my assignment to write a class and 5 different objects and to display the difference.
The professor said that we should use default constructors and the book says this:
A default constructor is a constructor which can be called with no arguments (either defined with an empty parameter list, or with default arguments provided for every parameter).
I am doing exactly what the teacher did; can you please tell me why it says it can't find data
?
#include <iostream>
using namespace std;
class theC
{
private:
string data;
public:
theC() {
printf("default\n");
}
};
int main()
{
theC c1();
theC c2();
theC c3();
theC c4();
theC c5();
c1.data = "different object 1";
c2.data = "different object 2";
c3.data = "different object 3";
c4.data = "different object 4";
c5.data = "different object 5";
cout << c1.data << c2.data << c3.data << c4.data << c5.data;
return 0;
}