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

template class data member not found!

Code:
=========================================
template <class T, int Len>
class COciVariable
{
public:
T m_Var[Len];
};

template <class T>
class COciVariableEx : public COciVariable<T, 1>
{
public:
void operator = ( const T & Var )
{
m_Var = Var;
}
};
===========================================
Platform:
===========================================
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
============================================
Error:
============================================
In file included from main.cpp:1:
test.h: In member function `void COciVariable2Ex<T>::operator=(const
char&)':
test.h:35: error: `m_Var' undeclared (first use this function)
test.h:35: error: (Each undeclared identifier is reported only once for
each function it appears in.)
Why? PLS help me! Thx!!!

Mar 9 '06 #1
3 1960

alex wrote:
Code:
=========================================
template <class T, int Len>
class COciVariable
{
public:
T m_Var[Len];
};

template <class T>
class COciVariableEx : public COciVariable<T, 1>
{
public:
void operator = ( const T & Var )
{
m_Var = Var;
}
};


Implement operator= like so:

void operator= ( const T & Var )
{
this->m_Var = Var;
}

Greg

Mar 9 '06 #2
Standard C++ says that nondependent names are not looked up in
dependent base classes. To correct the code you're to make m_Var
dependent. You can do it in two ways: this->m_Var or COciVariable<T,
1>::m_Var.
See "two-phase lookup" to get additional information.

Mar 9 '06 #3
And as you m_Var is an array you should do this

public:
void operator = ( const T & Var )
{
this->m_Var[ 0 ] = Var;
}
};

alex a écrit :
Code:
=========================================
template <class T, int Len>
class COciVariable
{
public:
T m_Var[Len];
};

template <class T>
class COciVariableEx : public COciVariable<T, 1>
{
public:
void operator = ( const T & Var )
{
m_Var = Var;
}
};
===========================================
Platform:
===========================================
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
============================================
Error:
============================================
In file included from main.cpp:1:
test.h: In member function `void COciVariable2Ex<T>::operator=(const
char&)':
test.h:35: error: `m_Var' undeclared (first use this function)
test.h:35: error: (Each undeclared identifier is reported only once for
each function it appears in.)
Why? PLS help me! Thx!!!

Mar 9 '06 #4

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

Similar topics

2
by: Alex Vinokur | last post by:
========================================= Windows 2000 CYGWIN_NT-5.0 1.3.22(0.78/3/2) GNU gcc version 3.2 20020927 (prerelease) ========================================= Here is some program...
4
by: Gert Van den Eynde | last post by:
Hi all, A beginners question.... I've got a template class template <class T> classA {...} In an other class, I want to pass a pointer to an instance of classA as a function argument....
3
by: David Komanek | last post by:
Hi all, I am trying to learn more about how to use g++/Cygwin to produce dll files on WinXP. And I have a problem which at the first look seems to be an obvious dll-export problem, but I don't...
5
by: henkoo | last post by:
i want to explicit instantiate a member function of a class template, and got some error, can anyone give some advice to correct it? 3x complier: g++ 3.2 #include <iostream> #include...
1
by: Kai-Uwe Bux | last post by:
Hi folks, I would like to know which clause of the standard rules out this: template < typename eval > struct recursive_template { typedef typename eval::enum_type Enum;
1
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...
6
by: Howard | last post by:
Hi, I have a function in three unrelated but similar classes. The code in the member functions is identical for all three classes. What I want is to make a template which defines the function,...
5
by: StephQ | last post by:
This is from a thread that I posted on another forum some days ago. I didn't get any response, so I'm proposing it in this ng in hope of better luck :) The standard explanation is that pointer...
1
by: scripty | last post by:
Hello, I am trying to implement hash table functionality using templates. I need to declare the hash table element as a struct or class inside the HTable template... I get...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.