0
Creating object that exists with numbers
class account{ int money; }; int main(){ int id; cin>> id; account id; // <-- i want this } Can't we create object with numbers. Must it be string? (im using c++)
4 Answers
+ 1
hope this helps
#include <iostream>
using std::cin;
using std::cout;
class account{\
public:
int money;
};
int main(){
int id;
account anAccount;
cin >> id;
anAccount.money=id; // <-- i want this
cout << anAccount.money;
}
+ 1
is this possible to do your project with strings like this :
_123456
0
no no, I meant i want to create class that exists from numbers, for example:
int main(){
int id = 242381848;//for example this is id of user
account id; //im creating object
//To access user's money,name, adress etc. I'm going to use of user's id. for example
cout<< "Please enter your id: ";
cin>> id;
//The thing that I want is to accessing money, name etc. of user with id ( id is going to be object )
cout<< id.money;
0
idk