Not necessarily hard I just have a hard time where to exactly inherit the , I have a bass class and 2 separate classes which inherit the base class

Lets class base class - Class A

Other two classes - Class B and Class C

Class A has the following pseudo code schema

public:
        int returnDay() const;
        float returnAmount() const;
        string returnCust() const;
       Constructor(parametized default values);
       void Initialize(int, float, string);
private:
   int day;
  float amount;
  string customer;

Class B is very similiar

public:
        int returnQuantity() const;
        string returnItemNum() const;
       Constructor(parametized default values);
       void Initialize(int, float, string, string, int);
private:
   string itemNumber;
  int quantity

Class C is very much like B
If i know how to implement class B while inheriting from the base Class A then I can do it to the other class

I dont exactly know what to inherit my guess is the Initialize function in the base class when your implementing the Initialize function in Class B ? but who knows its not working quite right

To my knowledge you can't specify what to inherit and what not. You either inherit the whole shebang or you don't inherit anything. I always am receptive to being shown wrong, and thereby learn in the process, however.

Well my best guess is that the function used from the base class into either separate classes is the Initialize function

However If say in the implementation of class B or C

In my implementation file I have

void Class B::Initialize(int, float, string, int, string) : Initialize(...

It would not work because I believe it has to be called as a constructor
and when I call it in the function it doesnt work either Im sort of lost

To my knowledge you can't specify what to inherit and what not. You either inherit the whole shebang or you don't inherit anything. I always am receptive to being shown wrong, and thereby learn in the process, however.

You know I wasn't 100% sure. Then I tried it. Tell me what you think :

#include<iostream>
#include<sstream>

using namespace std;

class A
{
private :
	int aVar;

public:
	
	static void attack() { cout <<"Rarr\n"; }	

	int run() { return 0; }

	struct A_o 
	{
		int x;
		A_o() { x = 0; }	
		void Roar(){ A::attack(); }
	};
};

class B : public A::A_o
{
public:
	void Roar(){
		this->A_o::Roar(); 
	}
	
	//Error below
	//void flee() { A::run(); };
};

int main()
{ 	
	B classB;

	classB.Roar();

	return 0;

}

Its inheriting A_o( part of A) and not the whole class A, if that
is what you mean.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.