473,757 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

static data member

what is meaning of this? (MS VC++ .NET)
----------------------
Linking...
machine.obj : error LNK2001: unresolved external symbol "private: static class std::vector<str uct GessoidMachine: :Resolution,cla ss
std::allocator< struct GessoidMachine: :Resolution> > GessoidMachine: :Machine::resol ution"
(?resolution@Ma chine@GessoidMa chine@@0V?$vect or@UResolution@ GessoidMachine@ @V?$allocator@U Resolution@Gess oidMachine@@@st d@@@std@@A)
machine.obj : error LNK2001: unresolved external symbol "private: static struct SDL_Surface * GessoidMachine: :Machine::scree n"
(?screen@Machin e@GessoidMachin e@@0PAUSDL_Surf ace@@A)
machine.obj : error LNK2001: unresolved external symbol "private: static int GessoidMachine: :Machine::resol ution_index"
(?resolution_in dex@Machine@Ges soidMachine@@0H A)
..\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_inde x;
static SDL_Surface *screen;
};
----------------------
Jul 22 '05 #1
2 7676
"<- Chameleon ->" <ch******@hotma il.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<str uct GessoidMachine: :Resolution,cla ss
std::allocator< struct GessoidMachine: :Resolution> >
GessoidMachine: :Machine::resol ution"
(?resolution@Ma chine@GessoidMa chine@@0V?$vect or@UResolution@ GessoidMachine@ @
V?$allocator@UR esolution@Gesso idMachine@@@std @@@std@@A) machine.obj : error LNK2001: unresolved external symbol "private:
static struct SDL_Surface * GessoidMachine: :Machine::scree n"
(?screen@Machin e@GessoidMachin e@@0PAUSDL_Surf ace@@A)
machine.obj : error LNK2001: unresolved external symbol "private:
static int GessoidMachine: :Machine::resol ution_index"
(?resolution_in dex@Machine@Ges soidMachine@@0H A) .\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_inde x;
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::resolu tion;
int Machine::resolu tion_index;
SDL_Surface *Machine::scree n;

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
4405
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 reffers in all objects of this class to the same data Or in other word by using the static keyword all objects of one class can share data. (This is what I want)
11
4614
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 variables". However, this doesn't seem entirely correct. It also doesn't mention whether static member functions can access protected and private member data and methods (and I couldn't spot this in the FAQ). I have a class row<Row> which derives from...
8
1836
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' handles) instances? Thanks in advance for any help
8
4589
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: VarArray::funct were an extern, but it is declared in the same file (q.v.). What is the remedy for this? =================
14
2871
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
3171
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. And I haved used the sizeof operator to test a class which has a static data member, the class size is all the nonstatic data member except the static data member. In compiler's view, is the static data member constructed after the whole class...
1
2298
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 the data member is the same for every instance of that class? I would expect so, but I noticed something that makes me doubt a little.
10
32206
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: ----------------------------------------------------------------------------------- //person.h class Person {
6
3758
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 there a provision to indicate that a static member function does not modify the static data members but only uses their values ? Kindly explain. Thanks V.Subramanian
15
7871
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
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
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,...
0
10069
Oralloy
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...
1
9884
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,...
1
7285
isladogs
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...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
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...

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.