473,505 Members | 16,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I use a class name Rect when there is a function has the same name

Hi,

I have a class called 'A', and it has a method called 'Rect(int x, int
y, int w, int h)'

And I have another class called 'Rect'.

When I called 'Rect* in other method of A, I get this compiler error:
void A::aMethod() {
Rect* lastRect;
// ...
}

error: 'lastRect' was not declared in this scope

I think the compiler confuses the class Rect with the method Rect.

Can you please tell me if there is a work around for my problem? I
cant' rename the class Rect or the method 'Rect' in class A since they
are both legacy code.

Thank you for any idea.

Feb 12 '07 #1
2 1336
yi*****@gmail.com wrote:
Hi,

I have a class called 'A', and it has a method called 'Rect(int x, int
y, int w, int h)'

And I have another class called 'Rect'.

When I called 'Rect* in other method of A, I get this compiler error:
void A::aMethod() {
Rect* lastRect;
// ...
}

error: 'lastRect' was not declared in this scope

I think the compiler confuses the class Rect with the method Rect.

Can you please tell me if there is a work around for my problem? I
cant' rename the class Rect or the method 'Rect' in class A since they
are both legacy code.
Put it in a namespace. Otherwise, you're pretty much SOL.
Feb 13 '07 #2
yi*****@gmail.com schrieb:
Hi,

I have a class called 'A', and it has a method called 'Rect(int x, int
y, int w, int h)'

And I have another class called 'Rect'.

When I called 'Rect* in other method of A, I get this compiler error:
void A::aMethod() {
Rect* lastRect;
Try this:

::Rect* lastRect;
// ...
}

error: 'lastRect' was not declared in this scope

I think the compiler confuses the class Rect with the method Rect.
--
Thomas
http://www.netmeister.org/news/learn2quote.html
Feb 13 '07 #3

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

Similar topics

15
9031
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
39
2022
by: Chetan Raj | last post by:
Hi All, One of my friend asked this question on C++ >>> Hi, Can u give an answer to this : We have the .h files for standard library. Consider any class (such as
21
3930
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
3
4223
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
4
16952
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in advance for any help! Problem: I am getting...
0
1614
by: bjpandapark | last post by:
Hi, I am working on my homework...and I have to do create a class where it can calculate the area of the rectangle while under these conditions.. 1. limit the width and length ...under 20...
9
2019
by: bunty | last post by:
Hi all, I am working on 16 bit app on windows. My problem is I am using windows RECT structure. on 16 bit windows it 's all member are declared as short which allows max 32767 max value. and...
0
2777
by: Kristopher Wragg | last post by:
Hi, I'm having a problem with XMLSerializer, I have classes like the following: public abstract class EulerObject { private Rectangle rect; private string guid = "";
10
1737
by: steve | last post by:
If I have an object I know I can get the name of the class but can I get the class name in the following scenario : public class ParentClass { public static string ClassName { get { return...
0
7103
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
7307
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,...
1
7021
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
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5614
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,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.