Hi all,
I am trying to implement singleton class having static method.
my requirement is as below:

A.h
Class A{
Public :
Static A* getInstance();
}

B.cpp
#include A.h
Class B : public class A{
A* A::getInstance()
{
//some code.
Return *A
}
}

D.cpp
#include B.h

A* pter = A::getInstance() // error: 'getInstance' is not a member of 'A'

please tell me what is wrong in this code.

Can you show me real code please? That example is not cutting it. And from your example, your code looks badly designed.

mate please use code tags "[ code ]" and "[ / code ]" when you
posting the source code.

And your program seems to have lots of errors.Where are the semicolons
after the end of the class declaration?

And include should be like this

#include "A.h"

too. Please submit the code with the code tags before someone rate bad on
your profile.

Thanks.

The below code is a psudeo code. Since i can t share my code becasue its a confidential code.
The Code is divided into two folders :
First Folder contains : We call that folder as "Folder 1"

A.h

Class A{
Public :
Static A* getInstance();
}

A.cpp contains nothing because its a non-concrete

B.h

#include A.h
class B : public A
{
  // some code
};

B.cpp

A* A::getInstance(){
    //some code.
    Return *A
}

In other folder : We call that folder as "Folder 2"

D.h

#include B.h
class D
{
	public : 

		void Initialize();
}

D.cpp

#include D.h

D::Initialize(){

	A* pter = A::getInstance() // error: 'getInstance' is not a member of 'A'
}

I am trying to build the code on CentOs.
As per my requirement I will build the Folder 2 first and then Folder 1...

Can you show me real code please? That example is not cutting it. And from your example, your code looks badly designed.

The below code is a psudeo code. Since i can t share my code becasue its a confidential code.
The Code is divided into two folders :
First Folder contains : We call that folder as "Folder 1"

A.h

Class A{
Public :
Static A* getInstance();
}

A.cpp contains nothing because its a non-concrete

B.h

#include A.h
class B : public A
{
  // some code
};

B.cpp

A* A::getInstance(){
    //some code.
    Return *A
}

In other folder : We call that folder as "Folder 2"

D.h

#include B.h
class D
{
	public : 

		void Initialize();
}

D.cpp

#include D.h

D::Initialize(){

	A* pter = A::getInstance() // error: 'getInstance' is not a member of 'A'
}

I am trying to build the code on CentOs.
As per my requirement I will build the Folder 2 first and then Folder 1...

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.