I have a class, and i try to create an object of it but it give me error in compilation.
The error is something like "]b]undefined reference to 'Game::PowerUp: :powerups[/b]", in constructor of Game::PowerUp.
The error also contain another 2 error : also are undefined reference but under ~PowerUp destructor.
it compiled well actually if i dont create an object of it in test.cpp(main program to create objects), but once i coded this " PowerUp* power = new PowerUp(t, s, 4, 4);" in test.cpp, the compilation fails and give that that error message.
here is my code: -
/*** Power Up class ***/
-
class PowerUp : public Health {
-
public:
-
PowerUp(
-
const Terrain* t,
-
Screen* s,
-
unsigned startX,
-
unsigned startY,
-
unsigned p = STD_POWER_UP
-
) : Health(t, s, startX, startY, p) {
-
powerups.insert(this);
-
}
-
virtual ~PowerUp() { powerups.erase(this); }
-
virtual void Use(Character* c) {
-
Health::Use(c);
-
delete this; // Powerups disappear once used
-
}
-
static PowerUp* Find(unsigned atX, unsigned atY) {
-
set<PowerUp*>::const_iterator it;
-
for (it = powerups.begin(); it != powerups.end(); it++) {
-
if ((*it)->xPos == atX && (*it)->yPos == atY) {
-
return (*it);
-
}
-
}
-
return 0;
-
}
-
virtual char GetSymbol() const { return '@'; }
-
private:
-
unsigned power;
-
static set<PowerUp*> powerups;
-
2 1637 Ganon11 3,652
Recognized Expert Specialist
Have you initialized the Set powerups in your .cpp file?
thanks Ganon11,
i have settled this problem 5 minutes ago.
yes, you're right. I didn't yet initialise the powerups static variable.
Thanks.
Nicky Eng.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: James Proctor |
last post by:
Hi there, im brand new to ASP. Ive done loads of VB coding and one of my
clients is intrested in a web based application, so im trying to play on and
learn it a tad. However im comming across lots of problems. Up until now ive
managed to sort most of them, but now im strugling. When i run my application
i keep getting this.
Server Error in '/WebApplication1' Application....
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I want my users to be able to select a report, click on a command
button on a form, which will then automatically create the report as a
pdf file and save it to the user's machine.
I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
|
by: James Proctor |
last post by:
Hi there, im brand new to ASP. Ive done loads of VB coding and one of my
clients is intrested in a web based application, so im trying to play on and
learn it a tad. However im comming across lots of problems. Up until now ive
managed to sort most of them, but now im strugling. When i run my application
i keep getting this.
Server Error in '/WebApplication1' Application...
|
by: Seok Bee |
last post by:
Dear Experts,
I've completed my console application and now wants to compile the
application and an executable file to be run at another location. However,
I've tried compiling that program in the command prompt with the following
command :
vbc Module1.vb /out:OEAutomation.exe /t:exe
I received a lot of error messages.
|
by: Patrick F |
last post by:
I keep getting this error message and i don't know whats the problem is and
how to solve it. I have a webproject with 2 components (dll) added to it. One
is called PhotoGallery and one is called Photo. Any suggestions on how to
solve this? i can't do much at the moment.
Server Error in '/PhotoGallery' Application.
--------------------------------------------------------------------------------
Cannot create/shadow copy 'Photo' when...
| |
by: Patrick F |
last post by:
I keep getting this error message and i don't know whats the problem is and
how to solve it. I have a webproject with 2 components (dll) added to it. One
is called PhotoGallery and one is called Photo. Any suggestions on how to
solve this? i can't do much at the moment.
Server Error in '/PhotoGallery' Application.
--------------------------------------------------------------------------------
Cannot create/shadow copy 'Photo' when...
|
by: subramanian100in |
last post by:
Consider the following program:
#include <iostream>
using namespace std;
class Base
{
public:
Base(int x = 0);
|
by: Rob |
last post by:
This actually compiles and works but it doesn't seem like the best
code, so I was wondering is there another way to do this?
template <typename Tvector<T>* addDepth(T)
{
return new vector<T>;
}
....a templated meth...
|
by: Mr. X. |
last post by:
Hello.
How can I create aspnetdb from scratch ?
(I want a script that create all table, views, etc... on that database).
Thanks :)
|
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...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| | |