Hi...
i'm trying to understand the concept of function name overloading in
c++.
to understand the resolving system it's important to understand the
diffrent
levels of typecasting (exact match, promotion, conversion, not
possible)
that is, what i don't really understand. so i tried do make a little
table:
| bool | char | unsig int | int | float | double
-----------------------------------------------------------
bool into | EM | PRO | PRO | PRO | |
-----------------------------------------------------------
char into | | EM | PRO | PRO | PRO | PRO
-----------------------------------------------------------
unsig into | | | EM | | |
-----------------------------------------------------------
int into | CON | CON | | EM | CON | CON
-----------------------------------------------------------
float into | | | | | EM | PRO
-----------------------------------------------------------
double into| CON | | | | | EM
(e.g.: float into double: PRO)
EM= exakt match
PRO= promotion
CON= conversion
NP= not possible
it would be a great help for me if someone could correct and complete
this table.
thanks a lot...
andy 2 2158
Andy schrieb: Hi...
i'm trying to understand the concept of function name overloading in c++. to understand the resolving system it's important to understand the diffrent levels of typecasting (exact match, promotion, conversion, not possible)
that is, what i don't really understand. so i tried do make a little table:
| bool | char | unsig int | int | float | double ----------------------------------------------------------- bool into | EM | PRO | PRO | PRO | | ----------------------------------------------------------- char into | | EM | PRO | PRO | PRO | PRO ----------------------------------------------------------- unsig into | | | EM | | | ----------------------------------------------------------- int into | CON | CON | | EM | CON | CON ----------------------------------------------------------- float into | | | | | EM | PRO ----------------------------------------------------------- double into| CON | | | | | EM
(e.g.: float into double: PRO) EM= exakt match PRO= promotion CON= conversion NP= not possible
it would be a great help for me if someone could correct and complete this table.
sorry for being impatient, but i'm just wondering why nobody answers to
my post.
is it useless to make a table like intended to do, or did i violate a
rule and my post is not as post need to be in this group?
please answer me!
Andy wrote: Andy schrieb:
Hi...
i'm trying to understand the concept of function name overloading in c++. to understand the resolving system it's important to understand the diffrent levels of typecasting (exact match, promotion, conversion, not possible)
that is, what i don't really understand. so i tried do make a little table:
| bool | char | unsig int | int | float | double ----------------------------------------------------------- bool into | EM | PRO | PRO | PRO | | ----------------------------------------------------------- char into | | EM | PRO | PRO | PRO | PRO ----------------------------------------------------------- unsig into | | | EM | | | ----------------------------------------------------------- int into | CON | CON | | EM | CON | CON ----------------------------------------------------------- float into | | | | | EM | PRO ----------------------------------------------------------- double into| CON | | | | | EM
(e.g.: float into double: PRO) EM= exakt match PRO= promotion CON= conversion NP= not possible
it would be a great help for me if someone could correct and complete this table.
sorry for being impatient, but i'm just wondering why nobody answers to my post. is it useless to make a table like intended to do, or did i violate a rule and my post is not as post need to be in this group?
please answer me!
You didn't violate any rules, I guess no-one found your topic
interesting or important enough to answer.
The C++ standard actually allows some leeway to implementors so I don't
think you can write one table that would work for all implementations .
For instance char -> unsigned int is a conversion if char is signed but
a promotion if char is unsigned.
Your table has some mistakes, bool to char is a conversion for instance,
There are no promotions to char. char to unsigned int may be a promotion
or a conversion, as explained above.
All the blanks in your table are conversions.
Hopefully that gives you enough information to complete the table.
john This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Lehn |
last post by:
Hi,
I have a question regarding the conversion of objects. When is the
conversion done by the constructor and when by the operator. My feeling
tells me that the constructor is preferred. But I couldn't find the
exact rule in the C++ standard.
And what if the classes have template parameters?
It would be great if somebody could get me a rough hint where in the
|
by: conrad |
last post by:
for something like printf("%lld\n", 1);
what section in the standard describes what type the argument "1"
is promoted to?
All I see is a section describing promotion from
float to double but nothing else.
--
nethlek
|
by: TTroy |
last post by:
Hello, I'm relatively new to C and have gone through more than 4 books
on it. None mentioned anything about integral promotion, arithmetic
conversion, value preserving and unsigned preserving. And K&R2
mentions "signed extension" everywhere.
Reading some old clc posts, I've beginning to realize that these books
are over-generalizing the topic. I am just wondering what the
difference between the following pairs of terms are:
1)...
|
by: Steve Gough |
last post by:
Could anyone please help me to understand what is happening here? The
commented line produces an error, which is what I expected given that
there is no conversion defined from type double to type Test. I
expected the same error from the following line, but it compiles fine.
The double is silently truncated to an int and then fed in to the
implicit conversion operator. Why does this happen? Is there any way
that I can keep the implicit...
|
by: Arvid Requate |
last post by:
Hello,
I'd like to understand why the following code does not compile. It
looks like a strangeness in connection with overload resolution for the
<complex> header:
The conversion operator double() of class B is called for the member
complex::operator*=(double) as expected, but not for operator*(complex,
double).
The effect is, that the template matching (or overload resolution)
| |
by: ReeceSeeSharp |
last post by:
Having difficulty trying to get this code in .NET (C#) to print out this string EXACTLY as it prints out within Java using a) the MD5 hashing algorithm and B). In Java here's how a string "ididnot" would print out
E#øðûÜ+œ_Z*º~
And here's the Java code
string pswd;
public String getPswd() {return pswd;}
public void setPassword(String passwd) {
|
by: sarathy |
last post by:
Hi,
What is integer promotion? How is it different from
arithmetic conversion?
Regards,
Sarathy
|
by: Neelesh Bodas |
last post by:
Can somebody please explain the fine difference between these two
clauses of the standard:
4.5 (Integral promotions)
4. An rvalue of type bool can be converted to an rvalue of type
int, with false becoming zero and true becoming one
4.7 (Integral conversions)
4. If the source type is bool, the value false is converted to zero
|
by: Rahul |
last post by:
Hi Everyone,
I have the following code,
class B;
class A
{
public : operator B();
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |