473,408 Members | 2,405 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,408 software developers and data experts.

[SOLVED] Must use 'this' to access member!

4
Hi,
the following piece of code can correctly compile (g++ 4.1.2) only if 'this' is specified. Otherwise, it gives the error: 'i' was not declared in this scope (?). Inheriting from, say, X<int> doesn't lead to this problem! I find this rather odd... any hints? Compiler bug?

template<class T> struct X {
int i; // dummy type
};
template<class T> struct Y : public X<T> {
Y() { this->i = 100; }
};

int main() {
Y<double> y; // dummy type
}
Oct 24 '08 #1
3 1167
Lifo
4
Hi,
the following piece of code can correctly compile (g++ 4.1.2) only if 'this' is specified. Otherwise, it gives the error: 'i' was not declared in this scope (?). Inheriting from, say, X<int> doesn't lead to this problem! I find this rather odd... any hints? Compiler bug?
Compiler bug: g++ 3.3.6 works fine, while 3.4.6 doesn't. Still didn't try last stable g++ available (4.3.2).
Oct 24 '08 #2
Lifo
4
Compiler bug: g++ 3.3.6 works fine, while 3.4.6 doesn't. Still didn't try last stable g++ available (4.3.2).
4.3.2 buggy, too! I'll notify it.
Oct 24 '08 #3
Lifo
4
for those who may be interested: NOT bug!

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37910
Oct 28 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Aakash Joshi | last post by:
is there any way we can access private member function of a class from outside. i know we can access private member data using void pointer
13
by: jt | last post by:
Being a newbie in C++ and comming from C, I can't find information on how to access a class member function outside its class. Below is a snippet of the class and its member function: look at...
2
by: Richard Lionheart | last post by:
Hi All, I generated a WebForm and created a Virtual Directory for it IIS. But I got an error message (shown below) saying something like my app lacked appropriate privileges. David Wang...
7
by: relient | last post by:
Question: Why can't you access a private inherited field from a base class in a derived class? I have a *theory* of how this works, of which, I'm not completely sure of but makes logical sense to...
5
by: ZikO | last post by:
Hi there. I have a problem. I have created nested classes but don't know how to access to inner classes. I know I can create objects: Hen Object; Hen::Nest ObjectNest; Hen::Nest::Egg...
7
bvdet
by: bvdet | last post by:
I provide shop drawings to structural steel fabricators with SDS/2 software (http://sds2.com) by Design Data (DD). I am not a programmer by education or trade and started writing scripts about 5...
9
by: fcvcnet | last post by:
Hi, I write a class class CSegment { public: CSegment(void); public: ~CSegment(void); public: CArray< CList< CPoint, CPoint& >, CList< CPoint, CPoint& >& m_curve;
9
by: maas | last post by:
Hello I have a problem when coding the statement stmt.execute("insert into Member values ("+mname+" ,"+mail+","+tel+")"); where mname, mail,tel are variables which the user inputs them and...
45
by: Bob Altman | last post by:
This code (Visual Studio 2005) should generate a compilation warning to the effect that I'm accessing a shared member through an instance variable (the "color" variable): Private Sub X(ByVal...
4
by: l.s.rockfan | last post by:
Hello, how do i have to call an inherited, templated class constructor from the initializer list of the inheriting, non-templated class constructor? example code: template<typename T>...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
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,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...

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.