Jump to content
  • Advertisement
Sign in to follow this  
Marianne

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

This topic is 4618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
you:
#ifndef T3PointGroup
#define T3PointGroup
and then
class T3PointGroup

Share this post


Link to post
Share on other sites
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!