0

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.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by archana.c07
0

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

Edited by firstPerson: n/a

0

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.

Edited by NicAx64: n/a

0

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...

0

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...

Edited by archana.c07: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.