|
-
January 8th, 2016, 04:21 PM
#8
Re: Standard C++98 Banking System example with OOPS
 Originally Posted by P_N_Data_System
Hello friends, here is my dummy code please tell me it is right or not and if i like to put class A, B, C, D in File1.cpp and main in File2.cpp then what to do?
How i can link File1.cpp and File2.cpp?
Code:
#include <iostream>
using namespace std;
class A
{
private:
string name;
protected:
void setName(string n)
{
name = n;
}
string getName()
{
return name;
}
virtual int display(int)=0;
};
class B : virtual public A
{
private:
static int noB;
public:
B()
{
++noB;
}
int display(int i)
{
cout << "i: " << i << endl;
++i;
return i;
}
static int getNoB()
{
return noB;
}
};
int B::noB = 0;
class C : virtual public A
{
private:
static int noC;
public:
C()
{
++noC;
}
int display(int i)
{
cout << "i: " << i << endl;
++i;
return i;
}
static int getNoC()
{
return noC;
}
};
int C::noC = 0;
class D
{
private:
public:
D()
{
}
int create()
{
int ch;
B objB, objB1;
C objC;
cout << "1. Call B" << endl;
cout << "2. Call C" << endl;
cin >> ch;
switch(ch)
{
case 1:
cout << objB.display(1) << endl;
break;
case 2:
cout << objC.display(2) << endl;
break;
}
}
void Test()
{
cout << "Total B count: " << B::getNoB() << endl;
cout << "Total C count: " << C::getNoC() << endl;
}
};
int main()
{
D d;
d.create();
d.Test();
return 0;
}
That's just random code you found on the internet. It has nothing to do with any kind of banking system. You seem to be missing the point that you're going to actually have to put in some effort to get help around here.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|