A singleton is a class of which there can and should only be one instance at any given time. If you're wanting to copy the object, then you shouldn't be using the singleton pattern in the first...
Type: Posts; User: UMR_Student
A singleton is a class of which there can and should only be one instance at any given time. If you're wanting to copy the object, then you shouldn't be using the singleton pattern in the first...
Is std::list<> not good enough?
> For all intents and purposes, a static member of a class *IS* a global variable.
class foo
{
public:
static int* getInstance();
private:
static int* m_instance;
};
You might also want to check out the Qt toolkit, and Qt's Designer form layout tool.
Yeah, I totally read that wrong. Sorry.
> References cannot change the object they refer to.
Oh no? Then explain the output of this program...
#include <iostream>
void foo(int& bar)
{
This may be a little off-topic on a C++ forum, but just at a first glance, this really sounds like a job for Stackless Python.
Well, I can't see much reason for having more than one instance for such a class (although maybe someone else can), so, yes, I would implement it as a singleton.
> It would be even more overhead doing it himself...
Awww, you ruined it. I was just going to let the obvious conclusion go unsaid.
Taken from http://www.boost.org/libs/serialization/doc/tutorial.html:
"The serialization library contains code for serialization of all STL classes."
The question then becomes, is the...
Sounds like you're having a blast at work :)
Yeah, and I completely understand your point of view there. It's just a matter of personal preference.
Maybe I'm missing something, but I'm a...
> The nodes of a linked list are an excellent example.
They're a viable one. I, however, would rather not abstract them, especially if the node type could be useful in other contexts (maybe a...
int main()
{
MyClass* myObject;
function1(myObject);
function2(myObject);
return 0;
}
> If a struct or class only makes sense in the context of another, it makes all the sense in the > world to make it nested.
Maybe you could give me an example of one such relationship?
> but it would seem logical that struct Point should be inside the linkedPointList class,
It would?
I am of the opinion that there is absolutely no reason to nest structures inside of classes....
There are two things you need to familiarize yourself with:
#1. Arrays (as MacGyver suggested)
#2. The TAB key
After you you've learned about these, here's a random nitpick for you:
int...
read(file, (char*)data2, sizeof(data2));
//Should be this
read(file, static_cast<char*>(&data2), sizeof data2);
The fastest I/O stuff is pretty much always OS-specific. For example, write() on Unix-based systems.
One of my projects right now is an AOL instant messenger bot. Lots of network programming because I'm creating my own implementation of the protocol, and some good AI stuff. Just food for thought
In addition to what Desolation said (I ditto all of that), just at a glance it looks like your functions are doing too much. Divide and ye shall conquer.
>Well thats the way i've been taught.
...
Gotcha, but is there any reason in particular why the struct has to be defined inside the class?
class foo
{
int bar();
};
int foo::bar()
{
return 0;
}
> ...can anyone point out my mistake?
Yes. You're writing a queue in C++.
You've forgotten to set the pointer that you've just free'd (BTW, use new/delete) to NULL, so the function deletes it,...
No offense, but that code is kinda funny. You have this nice polymorphic hierarchy going, and then you get to the main function and it's like you've never even heard of a for loop.
Teasing aside,...
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int roll_die();
void display( int [] );
//This is kind of stupid, but whatever