Name: Anonymous 2009-03-26 17:24
Yesterday I was assigned a project for my computer science class.
We're supposed to be using header files with our class definitions, but our teacher never really explained how header files work. This has lead me to a problem.
Here's what I'm looking at:
=====foo.h=====
class Foo
{
private:
const int MAX_ENTRIES;
int array[MAX_ENTRIES];
public:
Foo();
};
=====foo.cpp=====
class Foo
{
public:
Foo::Foo()
{
MAX_ENTRIES = 25;
}
}
As you can tell by my posting here, this isn't working. Is there anyway to define the size of the array using a named constant, or am I going to have to use a literal constant?
We're supposed to be using header files with our class definitions, but our teacher never really explained how header files work. This has lead me to a problem.
Here's what I'm looking at:
=====foo.h=====
class Foo
{
private:
const int MAX_ENTRIES;
int array[MAX_ENTRIES];
public:
Foo();
};
=====foo.cpp=====
class Foo
{
public:
Foo::Foo()
{
MAX_ENTRIES = 25;
}
}
As you can tell by my posting here, this isn't working. Is there anyway to define the size of the array using a named constant, or am I going to have to use a literal constant?