473,322 Members | 1,846 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,322 software developers and data experts.

static data member

what is meaning of this? (MS VC++ .NET)
----------------------
Linking...
machine.obj : error LNK2001: unresolved external symbol "private: static class std::vector<struct GessoidMachine::Resolution,class
std::allocator<struct GessoidMachine::Resolution> > GessoidMachine::Machine::resolution"
(?resolution@Machine@GessoidMachine@@0V?$vector@UR esolution@GessoidMachine@@V?$allocator@UResolution @GessoidMachine@@@std@@@std@@A)
machine.obj : error LNK2001: unresolved external symbol "private: static struct SDL_Surface * GessoidMachine::Machine::screen"
(?screen@Machine@GessoidMachine@@0PAUSDL_Surface@@ A)
machine.obj : error LNK2001: unresolved external symbol "private: static int GessoidMachine::Machine::resolution_index"
(?resolution_index@Machine@GessoidMachine@@0HA)
..\Debug/main.exe : fatal error LNK1120: 3 unresolved externals
----------------------

The error is in this code: (All member functions & data are static because I want only one instance of "Machine" in my project and I
want access in any data member without this->
----------------------
class Machine {
public:
static member1(arg1, arg2);
static member2();
.......
private:
// handle all resolutions supported from system
static vector <Resolution> resolution;
static int resolution_index;
static SDL_Surface *screen;
};
----------------------
Jul 22 '05 #1
2 7603
"<- Chameleon ->" <ch******@hotmail.NOSPAM.com> wrote in message
news:bv**********@nic.grnet.gr
what is meaning of this? (MS VC++ .NET)
----------------------
Linking...
machine.obj : error LNK2001: unresolved external symbol "private:
static class std::vector<struct GessoidMachine::Resolution,class
std::allocator<struct GessoidMachine::Resolution> >
GessoidMachine::Machine::resolution"
(?resolution@Machine@GessoidMachine@@0V?$vector@UR esolution@GessoidMachine@@
V?$allocator@UResolution@GessoidMachine@@@std@@@st d@@A) machine.obj : error LNK2001: unresolved external symbol "private:
static struct SDL_Surface * GessoidMachine::Machine::screen"
(?screen@Machine@GessoidMachine@@0PAUSDL_Surface@@ A)
machine.obj : error LNK2001: unresolved external symbol "private:
static int GessoidMachine::Machine::resolution_index"
(?resolution_index@Machine@GessoidMachine@@0HA) .\Debug/main.exe :
fatal error LNK1120: 3 unresolved externals
----------------------

The error is in this code: (All member functions & data are static
because I want only one instance of "Machine" in my project and I
want access in any data member without this->
----------------------
class Machine {
public:
static member1(arg1, arg2);
static member2();
.......
private:
// handle all resolutions supported from system
static vector <Resolution> resolution;
static int resolution_index;
static SDL_Surface *screen;
};
----------------------


static data members are like member functions: you declare them in the
header file and then define them in the .cpp file. Basically, storage is
allocated for ordinary data members when you define an object of the class.
But static data members are independent of any class object and hence you
need to define them separately in order for storage to be allocated for
them.

Thus your .cpp file needs to contain:

vector <Resolution> Machine::resolution;
int Machine::resolution_index;
SDL_Surface *Machine::screen;

Note that you must omit the static keyword in these definitions.
--

John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #2
Aaaaaaaaa!!!!!!

How much idiot I am?
Jul 22 '05 #3

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

Similar topics

29
by: Alexander Mahr | last post by:
Dear Newsgroup, I'm somehow confused with the usage of the static keyword. I can see two function of the keyword static in conjunction with a data member of a class. 1. The data member...
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
8
by: SJ | last post by:
Hi: I have a class which has a static member function. The function implements something common to all instances. How can the static member function know all of the (Get access to the instances'...
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:...
14
by: Mike Hewson | last post by:
Have been researching as to why: <example 1> class ABC { static const float some_float = 3.3f; }; <end example 1>
1
by: mangalalei | last post by:
A static data member can be of the same class type as that of which it is a member. A nonstatic data member is restricted to being declared as a pointer or a reference to an object of its class. ...
1
by: Frederiek | last post by:
Hi, When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. Does that mean that the address of...
10
by: shanknbake | last post by:
I'm getting the following compile-time error: error C2352: 'Person::getCount' : illegal call of non-static member function Here is my getCount function declaration:...
6
by: subramanian100in | last post by:
why can't a static member function be declared as const ? We can declare a non-static member function as const, to indicate that it does not modify the non-mutable data members. In the same way, is...
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.