473,779 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help - Advanced architecture

Hello,

I need a little help. I try to write the following architecture :

an abstract template class A

Two classes derived from class A : the classes B and C which are
concrete.

The class A contains a static method called CreateA which allows to
instanciate
one of the two subclasses depending external criterias.

//-------------------------------------------------------

This is implemented by the following code:

template <class T> class A
{
public:
virtual ~A() {};
virtual T& MethodOne() = 0;
static A<T>* CreateA(bool p_bParam = false);
};

//-------------------------------------------------------

template <class T> class B
: public template <class T> class A
{
public:
B();
virtual ~B() {};
virtual T& MethodOne() {return m_oAttribut;};

protected:
T m_oAttribut;
};

//-------------------------------------------------------

template <class T> class C
: public template <class T> class A
{
public:
C();
virtual ~C() {};
virtual T& MethodOne() {return m_oAttribut;};

protected:
T m_oAttribut;
};

//-------------------------------------------------------

template<class T>
void A<T>::CreateA(b ool p_bParam /*= false*/)
{
if(p_bParam)
return new B<T>;
else
return new C<T>;
}

//-------------------------------------------------------

I use this code in a class D :

class D
{
D();
~D();

protected:

A<long>* toto;
}

D::D()
{
toto = A<long>::Create A(true);
}
And I have a problem during the link step : Error XXX - Undefined
symbol A<long>::Create A(bool)

I work with the standard compiler provided par AIX 5.1 (xlC) et the
standard linker (ld).

Can someone help me ?

Is it possible to implement this architecture with standard C++ ?

Thanks for your help.

David2511.
Jul 22 '05 #1
1 1308
David2511 wrote:
I need a little help. I try to write the following architecture :

an abstract template class A

Two classes derived from class A : the classes B and C which are
concrete.

The class A contains a static method called CreateA which allows to
instanciate
one of the two subclasses depending external criterias.

//-------------------------------------------------------

This is implemented by the following code:

template <class T> class A
{
public:
virtual ~A() {}; ^^
Extraneous semicolon. Remove it.
virtual T& MethodOne() = 0;
static A<T>* CreateA(bool p_bParam = false);
};

//-------------------------------------------------------

template <class T> class B
: public template <class T> class A
template<class T> class B : public A<T>
{
public:
B();
virtual ~B() {};
virtual T& MethodOne() {return m_oAttribut;};
Remove the extraneous semicolons.

protected:
T m_oAttribut;
};

//-------------------------------------------------------

template <class T> class C
: public template <class T> class A
template<class T> class C : public A<T>
{
public:
C();
virtual ~C() {};
virtual T& MethodOne() {return m_oAttribut;};
Drop the extraneous semicolons here too.

protected:
T m_oAttribut;
};

//-------------------------------------------------------

template<class T>
void A<T>::CreateA(b ool p_bParam /*= false*/)
template<class T>
A<T>* A<T>::CreateA(b ool p_bParam /*= false */)
{
if(p_bParam)
return new B<T>;
else
return new C<T>;
}

//-------------------------------------------------------

I use this code in a class D :

class D
{
D();
~D();

protected:

A<long>* toto;
} ;
^^^
Here you lost a semicolon.

D::D()
{
toto = A<long>::Create A(true);
}
It is better to initialise than to assign. Rewrite as

D::D() : toto(A<long>::C reateA(true))
{
}


And I have a problem during the link step : Error XXX - Undefined
symbol A<long>::Create A(bool)

I work with the standard compiler provided par AIX 5.1 (xlC) et the
standard linker (ld).

Can someone help me ?
See above.

Is it possible to implement this architecture with standard C++ ?


As soon as you have defined all the necessary functions, it should be OK.

V
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1762
by: Jason Sirota | last post by:
I am an advanced database and vb programmer but recently my position has called for advanced archtecture descisions enterprise-wide. Although I have quite a bit of knowledge on designing relational and normalized data structures I would like to further my knowledge on large-scale distributed database design and maintenance. Can anyone suggest a decent to good book covering some of the more advanced topics of enterprise databases and...
7
1260
by: abhishekjha10 | last post by:
Can I get some help on the following question " what do u mean by advanced architecture of c++ ?" This question was asked in an interview.
6
1328
by: abhishekjha10 | last post by:
i was asked this question in an interview. the question is that " what do u mean by advanced architecture of c++" i was unable to answer. what can be the answer ?
3
14520
by: RAJESH | last post by:
I am working with c# and asp.net in developing web applications, iam using ..netframework 1.1 ,i want to know what is the need of 3-tier or 4-tier architecture in our application development.what is its part when some body is using our application.plese give links where i can find the answer.
11
2140
by: Larry | last post by:
I will be teaching an eCommerce application development course using ASP.Net after many years of having taught classic ASP. (Course was interrupted by 18 months in the Middle East with my Army Reserve unit.) I need a textbook recommendation for a particular need. As I have delved into ASP.Net I find that I want to teach the course by emphasizing coding in the code behind pages but most of the books targeted at beginners to ASP use...
3
1640
by: Julia | last post by:
I need help with architecture design,please: I have a server which constantly downloading messages from the internet and store them inside a data base. the server have two administrators options: one is a local windows application,and the second is a web application The administrator can either delete messages,add new messages,and send messages
10
1489
by: pcthug | last post by:
Hi All, I am creating multi-tier app in vb.net using visual studio .net. I create a invoice.vb class file with properties, events and methods. This also has a line item collection class (lineitem.vb & lineitems.vb). I create a form (form1.frm) and write the corresponding code to initialize an invoice object, there are textboxes on the form to display the data, an update and load button. My data is stored in an access database.
6
3664
by: carsonbj | last post by:
I have an issue where the below operation works on a little-endian architecture but not on a big-endian architecture. I was under the impression that pointer arithmetic is architecture independant and bitwise operations are architecture dependant. The intention is to store two bytes, as chars, extracted from a short input parameter as: <code> void foo(short id_pair) { char *ptr = &id_pair;
2
2339
by: Bobby Edward | last post by:
I am creating an Advanced Search form. The user can select whether their phrase will search the "Title", "Description" or "All" fields. Obviously the WHERE clause will change, depending on the options they select. Any suggestions on how to implement this? Is the FilterExpression on the DataSource powerful enough to do this? How have you done similar things? I am using a 3 tiered architecture.
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.