473,378 Members | 1,495 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,378 software developers and data experts.

default expression type

does the standard guarantee that the type of an expression
is implicitly void as it does for functions?

for example:

int i = 0xff;

i;

does the type implicitly have void
since it isn't used for anything.
Nov 14 '05 #1
1 1166
j0mbolar wrote:
does the standard guarantee that the type of an expression
is implicitly void as it does for functions?

for example:

int i = 0xff;

i;

does the type implicitly have void
since it isn't used for anything.


Expressions have a type and a value.
In the statement:
i;
the type is "int" and its value is 0xFF. There does not have
to be any conversion to "void".

The compiler is free to optimize expressions and statements.
The expression above does not change any variables or memory
locations, so a good compiler will remove it from the code.

In the statement:
i = i + 5;
it still has type "int", but the value will be the result
of "i". The compiler does not convert its type, nor does
it need to. The compiler usually does not remove this
kind of statement.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #2

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

Similar topics

14
by: ago | last post by:
Is it possible to have a default value associated python objects? I.e. to flag an attribute in such a way that the assignment operator for the object returns the default attribute instead of the...
11
by: Greenhorn | last post by:
Hi, K&R says that "floating point constants contain a decimal point (123.4) or an exponent (1e-2) or both; their type is double; unless suffixed. The suffixes f or F indicate a float constant; l...
2
by: mukesh | last post by:
Can we use expression in default value for a table field for example – IIf(Table-1.field-1=table-2 . field-1, table-1.field-2, 0) Interpretation – If field-1 of table -1 is like/equal to...
1
by: Arndt Jonasson | last post by:
The definition of XPath 1.0 says "A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. This is the same way expansion is done...
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
12
by: claudiu | last post by:
Hi, I'll go straight to the first question. Why does the code below compile? void f(int i = 0); int main() { (&f)();
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
6
by: Tim Frink | last post by:
Hi, how can I set default values to template parameters? I've this code: class A { template<typename T> void foo( string = "", T* = 0, bool (T::*func)(void) = 0 );
43
by: kenneth | last post by:
Dear all, I have encountered this weird problem. I have a class definition with an __init__ argument 'd' which defaults to {}. This argument is put in the 'self.d' attribute at initialization...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.