Sign in to follow this  
Marianne

C++ problem (why does it assume my class is an union?)

Recommended Posts

Marianne    163
hi, i just can't understand this one. I created a class like any other classes i've ever created - but at compile time i get "Error: an anonymous union cannot have function members" However i never used the Union keyword but only the Class keyword! here's the header of my class... any idea what's the problem?? (T3 is the prefix i use to all classes in my 3D engine so don't wonder what it is)

#ifndef T3PointGroup
#define T3PointGroup

#include <vector>
#include "T3Coord.h"
using namespace std;

class T3PointGroup {
    int point_amount;
    
public:
    void doSomething();
    vector<T3Coord*> coords;
};

#endif



And i also get another error i don't get.... anyone knows what "*** malloc_zone_malloc[1447]: argument too large: 4286463584" means when adding something to a vector? thanks

Share this post


Link to post
Share on other sites
dave    2187
What happens when you take out the vector and remove T3Coord.h inclusion.

Only the error might actually lie in there.

Oh and don't do:

using namespace std;

It's lazy and inexplicit.

ace

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
you:
#ifndef T3PointGroup
#define T3PointGroup
and then
class T3PointGroup

Share this post


Link to post
Share on other sites
Marianne    163
Quote:
Original post by Anonymous Poster
you:
#ifndef T3PointGroup
#define T3PointGroup
and then
class T3PointGroup



Arrr your right i feel incredibly stupid now

thanks

Share this post


Link to post
Share on other sites
dave    2187
Quote:
Original post by Anonymous Poster
you:
#ifndef T3PointGroup
#define T3PointGroup
and then
class T3PointGroup


He has,

Is the file a .CPP file and not a .C file?

Share this post


Link to post
Share on other sites
CoreMeltdown    186
Quote:
Original post by Anonymous Poster
you:
#ifndef T3PointGroup
#define T3PointGroup
and then
class T3PointGroup


AP is right:
you are #defining an empty symbol (#define T3PointGroup), so when the preprocessor encounters "class T3PointGroup { etc.." it replace T3PointGroup with T3PointGroup #definition, which is actually empty.
Fix your conditional inclusion so that it doesn't match any class name.

Share this post


Link to post
Share on other sites
Marianne    163
i'm using GCC - the behaviour is strange. the error was actually pretty easy to spot but the error message was weird.

Another thing:

i declare 2 vectors one after the other - the second is not gonna work when adding things to it (with error: "*** malloc_zone_malloc[1447]: argument too large: 4286463584") . Look at this:

The weird thing is, if i declare them like this:

vector<T3PointGr*> tex_areas;
vector<T2Button*> poses_buttons;

poses_buttons is not going to work and the other will work fine. However if i declare them like this:

vector<T2Button*> poses_buttons;
vector<T3PointGr*> tex_areas;

tex_areas is not going to work while the other works fine.

Why does the order in which i declare the vectors make them behave weirdly??

Share this post


Link to post
Share on other sites
Roboguy    794
Quote:
Original post by ace_lovegrove
Quote:
Original post by Anonymous Poster
you:
#ifndef T3PointGroup
#define T3PointGroup
and then
class T3PointGroup


He has,

Is the file a .CPP file and not a .C file?


Why would that matter?

Share this post


Link to post
Share on other sites
Zahlman    1682
Quote:
Original post by Marianne
The weird thing is, if i declare them like this:

vector<T3PointGr*> tex_areas;
vector<T2Button*> poses_buttons;

poses_buttons is not going to work and the other will work fine. However if i declare them like this:

vector<T2Button*> poses_buttons;
vector<T3PointGr*> tex_areas;

tex_areas is not going to work while the other works fine.

Why does the order in which i declare the vectors make them behave weirdly??


Heap corruption, almost certainly. BTW, you should normally store vectors of instances, rather than vectors of pointers (unless polymorphism is required and/or there is a *simple* scheme by which the objects are shared).


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this