473,657 Members | 2,825 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 1342
yi*****@gmail.c om 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.c om 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
9053
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 the purpose of learning to work with C++. It therefore makes some sense for me to give the situation the amount of consideration presented below. To be quite honest, I'm amazed at the amount there is to say about such a seemingly simple...
39
2051
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
3963
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 nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
3
4245
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 of a subclassed DataGridTextBoxColum dos not seem like a practical way to do it. I have subclassed a DataGrid and overridden the OnPaint as such:
4
16974
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 this error when I try to pull up my edit page to display the current database information in the form, and then edit it on click:
0
1625
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 2. use set_length, get_length, set_width, and so on..and have the user input the length and width value 3. after the calculation is done, I have to use the function draw to draw the rectangle with some sort of symbol such as +++ or ===
9
2029
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 i require more valus to be stored for the Rect. So i created my own rect structure with long members. but when i do this call windows API GetWindowRect() fails. it does fill the rect structure with appropriate values. can any one help.
0
2791
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
1766
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 "ParentClass" }
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
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.