How do I declare an object function?

I've been looking everywhere for this and the answer is probably really simple, but I haven't been able to find it. I have a homework problem (graded through a machine, the website is turingscraft.com) the problem is as follows

Objects of the BankAccount class require a name (string) and a social security number (string) be specified (in that order)upon creation. Define an object named account , of type BankAccount , using the values "John Smith" and "123-45-6789" as the name and social security number respectively.

now as my understanding goes the correct code should be as such

BankAccount account;
account.name = John Smith;
account.social security number = 123-45-6789;

however when I do this I get a crap ton of compiler errors, and when I try and do what the errors specify I get even more errors. can someone please help me with this problem? If I get this one I'm sure I can build off of it for future problems.
The class definition should look something like this.

1
2
3
4
5
6
7
8
9
class Bankaccount{
  public:
   string name;
    string ssn;
   Bankaccount(string name_input, string ssn_input)
    : name(name_input),
      ssn(ssn_input)
    {       }
};


http://www.cplusplus.com/doc/tutorial/classes/
while I appreciate the help, the way the homework assignment works I am supposed to create an object called account of the class BankAccount which has already been defined for me. Sorry if that was unclear
BankAccount account("John Smith", "123-45-6789");
Last edited on
oh wow thanks, that was my first try and all I was missing was the parentheses, thanks a bunch!
Topic archived. No new replies allowed.