I have two classes(class A, class main). class main uses a pointer to
class A and class A uses a global pointer to main. My problem is I
keep getting these errors: :(
a.h(12) : error C2027: use of undefined type 'main'
a.h(4) : see declaration of 'main'
a.h(12) : error C2227: left of '->SomeDriver' must point to class/
struct/union/generic type
How do I fix this?
Thx ahead of time.
********
#include "main.h"
#include "A.h"
main *g_main = NULL;
int _tmain(int argc, _TCHAR* argv[])
{
g_main = new main;
g_main->a = new A;
g_main->a->Print();
g_main->a->SomeFunction() ;
return 0;
}
*********
#ifndef MAIN_H
#define MAIN_H
class A;
class main
{
public:
void SomeDriver()
{
printf ("driver called\n");
}
void PrintA()
{
a->Print();
}
A *a;
};
extern main *g_main;
#endif
*******
#ifndef A_H
#define A_H
class main;
class A
{
public:
void SomeFunction()
{
g_main->SomeDriver() ;
}
void Print()
{
printf ("Characters : a\n");
}
};
#endif 3 4141
Anonymous Infidel - Aborted Islam with a hanger wrote:
I have two classes(class A, class main). class main uses a pointer to
class A and class A uses a global pointer to main. My problem is I
keep getting these errors: :(
a.h(12) : error C2027: use of undefined type 'main'
a.h(4) : see declaration of 'main'
a.h(12) : error C2227: left of '->SomeDriver' must point to class/
struct/union/generic type
How do I fix this?
First off, you should probably rename your class from 'main' to smth
else. 'main' is the name of the function in your program that starts
its execution.
>
Thx ahead of time.
********
#include "main.h"
#include "A.h"
main *g_main = NULL;
int _tmain(int argc, _TCHAR* argv[])
There is no standard function _tmain.
{
g_main = new main;
g_main->a = new A;
g_main->a->Print();
g_main->a->SomeFunction() ;
return 0;
}
*********
#ifndef MAIN_H
#define MAIN_H
class A;
class main
{
public:
void SomeDriver()
{
printf ("driver called\n");
}
void PrintA()
{
a->Print();
Class 'A' hasn't been defined here yet. Consider pulling this
function out of the class definition into the translation unit.
}
A *a;
};
extern main *g_main;
#endif
*******
#ifndef A_H
#define A_H
class main;
class A
{
public:
void SomeFunction()
{
g_main->SomeDriver() ;
Although your 'A.h' is supposedly included after your 'main.h',
if it weren't, 'g_main' is undefined here. Consider pulling this
function out of the class definition into a translation unit.
}
void Print()
{
printf ("Characters : a\n");
}
};
#endif
Consider separating declarations and implementations of class
member functions. It's always a good idea for beginners.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On 6/6/2007 3:59 PM, Anonymous Infidel - Aborted Islam with a hanger wrote:
I have two classes(class A, class main). class main uses a pointer to
class A and class A uses a global pointer to main. My problem is I
keep getting these errors: :(
a.h(12) : error C2027: use of undefined type 'main'
a.h(4) : see declaration of 'main'
a.h(12) : error C2227: left of '->SomeDriver' must point to class/
struct/union/generic type
How do I fix this?
[code snipped] see one of his other posts.
What's wrong with you?
Do you read answers to your posts?
S.
--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
On Jun 6, 7:08 am, Stefan Naewe <nos...@please. netwrote:
On 6/6/2007 3:59 PM, Anonymous Infidel - Aborted Islam with a hanger wrote:
I have two classes(class A, class main). class main uses a pointer to
class A and class A uses a global pointer to main. My problem is I
keep getting these errors: :(
a.h(12) : error C2027: use of undefined type 'main'
a.h(4) : see declaration of 'main'
a.h(12) : error C2227: left of '->SomeDriver' must point to class/
struct/union/generic type
How do I fix this?
[code snipped] see one of his other posts.
What's wrong with you?
Do you read answers to your posts?
Yes. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
Hi everyone,
(I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group)
The issue I'm having is occuring in the IDE of VS.NET 2003, although I'm not sure what is actually causing the problem. I can't
summarize the issue, so please read on to find out more.
I've created a BaseDialogEditor class that allows a developer (namely me) to create Modal editors for controls at...
|
by: Mantorok Redgormor |
last post by:
#include <stdio.h>
struct foo { int example; struct bar *ptr; };
int main(void)
{
struct foo baz;
baz.ptr = NULL; /* Undefined behavior? */
return 0;
|
by: RoSsIaCrIiLoIA |
last post by:
On Mon, 07 Feb 2005 21:28:30 GMT, Keith Thompson <kst-u@mib.org>
wrote:
>"Romeo Colacitti" <wwromeo@gmail.com> writes:
>> Chris Torek wrote:
>>> In article <4205BD5C.6DC8@mindspring.com>
>>> pete <pfiland@mindspring.com> wrote:
>
>>> >If you have
>>> > int array;
>>> >then
|
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 like this
value = myHashtable;
then, is the value of "myKey" key is null, then the result is the same, as
|
by: matty |
last post by:
Hi,
I recently got very confused (well that's my life) about the
"undefined" value. I looked in the FAQ and didn't see anything about
it. On http://www.webreference.com/programming/javascript/gr/column9/
they say:
<snip>
The undefined property
A relatively recent addition to JavaScript is the undefined property.
| |
by: yb |
last post by:
Hi,
Looking for clarification of undefined variables vs. error in
JavaScript code.
e.g.
<script>
alert( z ); // this will be an error, i.e. an exception
</script>
|
by: Sharath A.V |
last post by:
I had an argument with someone on wheather this piece of code can
invoke undefined bahaviour.
I think it does not invoke any undefined behaviour since there is
sufficient memory space of 9 integer elements starting from the in the
address passed, but the other person insisted that it would invoke
undefined behaviour(for whatever reasons he had).
void fill(int *p)
{
|
by: VK |
last post by:
(see the post by ASM in the original thread; can be seen at
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b>
as an option)
As that is not in relevance to "new Array() vs " question or to the
array performance, I dared to move it to a new thread.
Gecko takes undefined value strictly as per Book 4, Chapter 3, Song 9
of Books of ECMA
:-)
|
by: yamitmehta |
last post by:
When I compile to code using g++arm of VxWorks 5.5 and put it on my
board i get the follwing undefined symbols:-
Cpool and Csingleton are template classes. CPool has the static member
variables:-ms_uCapacity ,ms_uAllocatedCount ,
ms_uLockCapacity ,ms_pmutex
-ld < yamit/apps1.out
Undefined symbol: _Q23m5tt5CPool1ZQ23m5t10CMarshaler$ms_uCapacity
(binding 1 type 0)
Undefined symbol: _Q23m5tt5CPool1ZQ23m5t10CMarshaler$ms_uAllocatedCount
|
by: blargg |
last post by:
Does ~0 yield undefined behavior? C++03 section 5 paragraph 5 seems to
suggest so:
The description of unary ~ (C++03 section 5.3.1 paragraph 8):
But perhaps "one's complement" means the value that type would have with
all bits inverted, rather than the mathematical result of inverting all
bits in the binary representation. For example, on a machine with 32-bit
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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...
| |
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
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |