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

is not a member error when trying to init members in constructor

This one is driving me nuts. I hope that it has just been a long day
and I am missing something stupid. Here is the .h and .cpp to the class
I am just starting:

//-----------------------------------------------------------------------------
//
// FILE: lg_data_table.h
#ifndef LG_DATA_TABLE_H_INCLUDED
#define LG_DATA_TABLE_H_INCLUDED 1
class lg_data_table : public data_table
{
public:
lg_data_table(xml_lst&);
~lg_data_table(){};
int get_current_row_num(){return row_nm_cnt;};
void incrmnt_row(){row_nm_cnt++;};
protected:
int row_nm_cnt;

};

#endif;

//-----------------------------------------------------------------------------
//
// FILE: lg_data_table.cpp

#include <baselib.h>
#include <lg_data_table.h>

lg_data_table::lg_data_table(xml_lst& xml_lst):row_nm_cnt(0)
{
//then i do stuff with xml_lst which is not important to this example
}

when I try to compile I get an error saying that "row_nm_cnt is not a
member of lg_data_table"

I have no idea what is going on. I haved tried adding other member
variables and the same things happens. Anyone have any ideas. I am lost
for now.

Aug 23 '06 #1
6 1387
al******@gmail.com wrote:
This one is driving me nuts. I hope that it has just been a long day
and I am missing something stupid. Here is the .h and .cpp to the
class I am just starting:

//-----------------------------------------------------------------------------
//
// FILE: lg_data_table.h
#ifndef LG_DATA_TABLE_H_INCLUDED
#define LG_DATA_TABLE_H_INCLUDED 1
class lg_data_table : public data_table
{
public:
lg_data_table(xml_lst&);
~lg_data_table(){};
int get_current_row_num(){return row_nm_cnt;};
void incrmnt_row(){row_nm_cnt++;};
protected:
int row_nm_cnt;

};

#endif;

//-----------------------------------------------------------------------------
//
// FILE: lg_data_table.cpp

#include <baselib.h>
#include <lg_data_table.h>

lg_data_table::lg_data_table(xml_lst& xml_lst):row_nm_cnt(0)
{
//then i do stuff with xml_lst which is not important to this example
}

when I try to compile I get an error saying that "row_nm_cnt is not a
member of lg_data_table"

I have no idea what is going on. I haved tried adding other member
variables and the same things happens. Anyone have any ideas. I am
lost for now.
Check your spelling (in the real code).

Check that your 'baselib.h' doesn't have the same include guards as
your 'lg_data_table.h' header.

Check that 'lg_data_table' class is defined at the point where you try
to define its constructor. Try declaring a global object of that type.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 23 '06 #2

al******@gmail.com wrote:
This one is driving me nuts. I hope that it has just been a long day
and I am missing something stupid. Here is the .h and .cpp to the class
I am just starting:

//-----------------------------------------------------------------------------
//
// FILE: lg_data_table.h
#ifndef LG_DATA_TABLE_H_INCLUDED
#define LG_DATA_TABLE_H_INCLUDED 1
class lg_data_table : public data_table
{
public:
lg_data_table(xml_lst&);
~lg_data_table(){};
int get_current_row_num(){return row_nm_cnt;};
void incrmnt_row(){row_nm_cnt++;};
protected:
int row_nm_cnt;

};

#endif;

//-----------------------------------------------------------------------------
//
// FILE: lg_data_table.cpp

#include <baselib.h>
#include <lg_data_table.h>

lg_data_table::lg_data_table(xml_lst& xml_lst):row_nm_cnt(0)
{
//then i do stuff with xml_lst which is not important to this example
}

when I try to compile I get an error saying that "row_nm_cnt is not a
member of lg_data_table"

I have no idea what is going on. I haved tried adding other member
variables and the same things happens. Anyone have any ideas. I am lost
for now.
What is data_table, xml_lst?

After commenting out the stuff that you didn't include ( data_table,
xml_lst ), and including a main, it compiles for me. The problem must
be something you didn't include.

-Brian

Aug 23 '06 #3
Victor Bazarov wrote:
al******@gmail.com wrote:
>This one is driving me nuts. [...]
#include <baselib.h>
#include <lg_data_table.h>

lg_data_table::lg_data_table(xml_lst& xml_lst):row_nm_cnt(0)
Also, I just noticed this: it's a BAD IDEA(tm) to name your argument
the same as the type of that argument.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 23 '06 #4
Thank you for the help. I still have not solved it but I have a ugly
temp work around. The lg_data_table class is called in another class
and when I create the lg_data_table object in that class I use a setter
to set the value of currnt_row_nm. I tried calling the setter from the
constructor and it did not recognize the function just like it did not
recognize the variable. I have not idea what is going on with that I
included the .h in the .cpp file so the class should know about these
things.

also the xml_lst and data_table classes are custom classes that are in
the baselibs.h. O well will have to look at this one again later.

thanks again for the quick help

Aug 23 '06 #5

<al******@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
Thank you for the help. I still have not solved it but I have a ugly
temp work around. The lg_data_table class is called in another class
and when I create the lg_data_table object in that class I use a setter
to set the value of currnt_row_nm. I tried calling the setter from the
constructor and it did not recognize the function just like it did not
recognize the variable. I have not idea what is going on with that I
included the .h in the .cpp file so the class should know about these
things.

also the xml_lst and data_table classes are custom classes that are in
the baselibs.h. O well will have to look at this one again later.

thanks again for the quick help
This indicates to me that the header file is not seen correctly by the .cpp
file.

The first thing that catches my eye is that your last line is

#endif;

That should be just

#endif

If that's not the problem, then here are some other ideas...

Perhaps you've got a copy of the file lying around somewhere, and that old
copy is being seen. Or, perhaps you've got another class with the same name
somewhere.

Or, perhaps you just need to clean and rebuild the entire thing.
(Sometimes, in VC++ especially, changes in header files don't seem to be
seen by the implementation files unless you do a complete rebuild.)

Another thought is that there are errors in the header file, and it's not
getting compiled, so that when the implementation file tries to use the
class, it's not fully defined.

And sometimes, if you copied the source from somewhere else, the line
endings are not correct, and the file isn't being parsed correctly. I have
also seen problems in some compilers if the last line of a header file was a
comment.

-Howard

Aug 23 '06 #6
Well I found the problem... there was a typo in the make and it was not
seeing the include.

I apologize for the wasted time. Thanks again to all those who helped.

Aug 23 '06 #7

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

Similar topics

7
by: Karsten Hochkirch | last post by:
Hi, I have just encountered a problem when calling a virtual member function in a constructor. Only the memberfunction of the parent class is called instead of the overloaded function. I...
6
by: Dan Huantes | last post by:
I was presented a problem today where a class had member variable that was an object of a templated class. The class wanted to instantiate the object as a private member variable and call a...
14
by: gurry | last post by:
Suppose there's a class A. There's another class called B which looks like this: class B { private: A a; public : B() { a.~A() } }
7
by: The|Godfather | last post by:
Hi everybody, I read Scotte Meyer's "Effective C++" book twice and I know that he mentioned something specific about constructors and destructors that was related to the following...
4
by: Josefo | last post by:
Hello, is someone so kind to tell me why I am getting the following errors ? vector_static_function.c:20: error: expected constructor, destructor, or type conversion before '.' token...
1
by: newbie | last post by:
This is a snippet from C++ FAQs, which I have never done--- when I do such a thing, I would declare function used by constructor ( in this example, init() ) as static. But I do understand that it...
4
by: danil52 | last post by:
Hello there. I have an abstract Base class with bunch of private static members and public static getters for those members. I want my Derived classes to call a static constructor and initialize...
7
by: Peter Olcott | last post by:
Why can a union have a member with a copy constructor?
3
by: NvrBst | last post by:
I'd like to do something like this but having a problem with the proper syntax in the constructor, maybe someone knows the correct syntax? ---MyClass.h--- #ifndef MYCLASS_H_ #define MYCLASS_H_...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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...

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.