473,378 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

usage of undefined class

Hello,

I would like to define a class (ListA) which can store elements of
another class (A). The problem is, that I want to use this class (ListA)
inside class A. (See code below.)
Of course I could use void* instead of A* in ListA but I would prefer a
way where do not always have to cast my pointers.
Is there a possibility to realize it (kind of) this way?

Thanks in advance!
Kris

class ListA {
private:
A * head;
public:
bool Add ( A * );
A * operator [] ( unsigned int );
...
};

class A {
public:
ListA * foo;
...
};

Jul 22 '05 #1
1 1421

"Kristoffer Mögle" <mo**@hrz.tu-chemnitz.de> a écrit dans le message de
news: br**********@anderson.hrz.tu-chemnitz.de...
Hello,

I would like to define a class (ListA) which can store elements of
another class (A). The problem is, that I want to use this class (ListA)
inside class A. (See code below.)
Of course I could use void* instead of A* in ListA but I would prefer a
way where do not always have to cast my pointers.
Is there a possibility to realize it (kind of) this way?

Thanks in advance!
Kris

class ListA {
private:
A * head;
public:
bool Add ( A * );
A * operator [] ( unsigned int );
...
};

class A {
public:
ListA * foo;
...
};


try this :

class A;

class ListA;

class ListA

{

A *m_pA;

};

class A

{

ListA *m_pListA;

};

should compile fine.

Jul 22 '05 #2

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

Similar topics

4
by: matthurne | last post by:
I am working through exercise 8-2 in Accelerated C++...I am implementing the function equal(b, e, b2) where b is an iterator for the first element in a container, e is an iterator pointing to one...
8
by: Scott J. McCaughrin | last post by:
The following program compiles fine but elicits this message from the linker: "undefined reference to VarArray::funct" and thus fails. It seems to behave as if the static data-member:...
7
by: Dave | last post by:
Hello all, In the code below, I use a pointer to an object under construction. Is the usage below legal? I have come across similar code at work. It compiles, but I'm not sure it's really...
0
by: Clemens Hintze | last post by:
Hello, I have a question concerning the usage of default constructed std::slice instances. Our company currently validate the GNU-G++ 3.4 compiler against the ISO/IEC 14882:2003 standard for...
9
by: rskeples | last post by:
I write a small program. char *foo(void); char *a = "I like C"; int main(void) { if((strcmp(a,foo())) { printf("\n i like c"); } }
1
by: Pavils Jurjans | last post by:
Hello, I am building custom hashtable class, and thinking about value retrieval issues. The thing is, that sometimes the hashtable value may contain value null. If someone is reading this value...
5
by: Steve | last post by:
Hi, I have a class like the following: public class Record { public double lastBasedOn; public double total; public double totalCount; public double sum;
4
by: Hermann Maier | last post by:
hi, i need to find out the memory usage of a specific function that i use in my program. this function does some recursive calculations and i want my program to display the amount of memory the...
6
by: Hunk | last post by:
Hi I have a question on usage of forward declarations of templates. While searching through this group , people suggested using forward declarations and typedefs for templates as // in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.