help needed

i am currently doing a mini bank account system using visual studio...i need help on using the header files...the question requires to use 3 header files for each class.these are the classes:

a)Accounts
b)CurrentAccounts
c)SavingAccounts

i have done the first part...can anyone tell me how to do a new class in a different header file..
You can use menu item "Add new item" and select from temolates the header file template.
what i mean was how to use the header file to do the Current Account class..
You put your class definition in the header file. This must contain the prototypes of the methods in the class, and the definitions of the data members of the class, e.g.

MyClass.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef MYCLASS_H
#define MYCLASS_H

class myClass
{
public:
  int  InterfaceMethod1();
  void InterfaceMethod2(int arg1);

private:
  int m_dataMember1;
  double m_dataMember2;
};

#endif // MYCLASS_H 


Normally, the actual method definitions go into an associated source code file. This source code file should include the header, because otherwise the compiler will have no way of knowing the class definition, e.g:

MyClass.cpp

1
2
3
4
5
6
7
8
9
10
11
#include "MyClass.h"

int MyClass::InterfaceMethod1()
{
  // Do some stuff and return a value
}

void MyClass::InterfaceMethod2(int arg1)
{
  // Do some stuff here
}


Then if any other file needs to know about MyClass - for example, if the code calls a method of MyClass, or instatiates a MyClass object, or a class definition inherits from MyClass - then it should include the header file to get the definition of the class.
Last edited on
Topic archived. No new replies allowed.