In cin statements, I am not putting in like objectpass.name, objectpass.n, objectpass.ch
So there is noting displaying.
If I put in properly in cin like objectpass.name, objectpass.n, objectpass.ch then it display correctly.
Now if I don't put in like objectpass.name, objectpass.n, objectpass.ch in cin rather just name, n, ch and same don't put in objectpass.name, objectpass.n, objectpass.ch in cout too. Then, display is correct.
My question is if I don't put in like objectpass.name, objectpass.n, objectpass.ch in cin, rather only put in name, n, ch, will the data store some other place?
In short, cin >>objectpass.name and cin>>name are two different variables?
How?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
using namespace std;
class ObPass {
private:
char name[40];
int n;
char ch;
public:
void disp(ObPass objectpass){
cout << "Enter Name: " << endl;
cin >> name;
cout << "Enter Integer: " << endl;
cin >> n;
cout<<"Enter Character: "<<endl;
cin >> ch;
cout << objectpass.name << objectpass.n << objectpass.ch << endl;
}
};
int main() {
ObPass object;
object.disp(object);
return 0;
}
|