473,399 Members | 4,254 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,399 software developers and data experts.

What's wrong Overloading []

Hello
My gcc copiler write this
TypEle& Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]
' and `
TypEle Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]'
cannot be overloaded

where TypEle is tempalte type, Tablica is table object.

TypEle Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]
I use for Tablica<int> tab1; int X;
X = tab1[23] and this work great but when I added
TypEle& Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]
for tab[1] = X it doen't work. With second operator i can't compile. How
should i corect this ??
Jul 22 '05 #1
1 1089
SinusX wrote:
My gcc copiler write this
TypEle& Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]
' and `
TypEle Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]'
cannot be overloaded

where TypEle is tempalte type, Tablica is table object.

TypEle Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]
I use for Tablica<int> tab1; int X;
X = tab1[23] and this work great but when I added
TypEle& Tablica<TypEle>::operator[](unsigned int) [with TypEle = int]
for tab[1] = X it doen't work. With second operator i can't compile. How
should i corect this ??


The compiler complains because the difference between the two functions is
only in the return value type. You probably mean to make the second one
'const':

TypEle Tablica<TypEle>::operator[](unsigned int) const;

while leaving the first one as is:

TypEle& Tablica<TypEle>::operator[](unsigned int);

See the difference? The one that returns a reference should not be const,
most likely.

Victor
Jul 22 '05 #2

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

Similar topics

34
by: Pmb | last post by:
I've been working on creating a Complex class for my own learning purpose (learn through doing etc.). I'm once again puzzled about something. I can't figure out how to overload the assignment...
15
by: Susan Baker | last post by:
Hello everybody, I'm new to C++ (I have some C background). I've read up on this topic a few times but it just dosen't seem to be sinking in. 1. Whats the difference between overloading and...
45
by: JaSeong Ju | last post by:
I would like to overload a C function. Is there any easy way to do this?
13
by: William Ryan | last post by:
I just picked up a copy of John Robbins' debugging book and started to look at disassembled code. Anyway, I hate optional Parameters in VB, but I was checking them out to see what IL is created. ...
18
by: Jm | last post by:
Hi all I feel stupid for asking this, but i just went to use the left() function from vb6 only to find it doesnt do what it used to under .NET. Im assuming theres something else now im meant to...
5
by: dragon1000 | last post by:
I have this book on C++ and evidently it seems to be going above my head when it comes to overloading. I have a few questions... 1) what is overloading and why would you use it? 2) What are...
15
by: lordkain | last post by:
is it possible to do some kind of function overloading in c? and that the return type is different
8
by: Skybuck Flying | last post by:
Hello, Visual Studio .Net 2005 (Win32) Compile error: Error 1 error C2804: binary 'operator +' has too many parameters <snipped> line 16 class TSkybuckInt32 { private:
10
by: Matthew | last post by:
Am I correct in thinking there is no method/function overloading of any kind in any version of PHP? Thanks, Matthew
3
by: abhighat4214 | last post by:
Hello All , I'm a little bit confused about function and constructor overloading in PHP 5.0 I know PHP does not support operator overloading. However if I have to realize the advantages of...
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
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: 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...
0
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
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,...
0
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...

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.