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

small doubt

Why won't this code compile?
#include <iostream.h>
void Print(int i);
void Print(float f, int skip = 0);
void main()
{
Print(3.3);
}
void Print(int i)
{
cout << "Integer" << endl;
}
void Print(float f, int skip)
{
cout << "Float";
if (skip != 0)
cout << endl;
}
Dec 19 '07 #1
9 1252
ya********@gmail.com wrote:
>
Why won't this code compile?
#include <iostream.h>
news:comp.lang.c++

--
pete
Dec 19 '07 #2
ya********@gmail.com schrieb:
Why won't this code compile?
Why do you think this code won't copile:

10 PRINT "DUH"
20 PRINT "NOW I KNOW"
30 GOTO 10

Because it's not C, maybe?

Greetings,
Johannes

--
"Viele der Theorien der Mathematiker sind falsch und klar
Gotteslästerlich. Ich vermute, dass diese falschen Theorien genau
deshalb so geliebt werden." -- Prophet und Visionär Hans Joss aka
HJP in de.sci.mathematik <47**********************@news.sunrise.ch>
Dec 19 '07 #3
ya********@gmail.com wrote:
Why won't this code compile?
#include <iostream.h>
This is not C. iostream is C++. Ask in comp.lang.c++
void Print(int i);
void Print(float f, int skip = 0);
void main()
This is illegal in both C and C++. Use int main().
{
Print(3.3);
}
void Print(int i)
{
cout << "Integer" << endl;
}
void Print(float f, int skip)
{
cout << "Float";
if (skip != 0)
cout << endl;
}
Your other problems are C++. Ask in comp.lang.c++

Dec 19 '07 #4
ya********@gmail.com said:
Why won't this code compile?
#include <iostream.h>
foo.c:1: iostream.h: No such file or directory

I guess that's why.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 19 '07 #5
ya********@gmail.com wrote:
Why won't this code compile?
[snip]
Print(3.3);
OT: C++

the constant 3.3 defaults to type double, use a cast

Print( (float) 3.3)
Dec 19 '07 #6
Why do you think this code won't copile:
>
10 PRINT "DUH"
20 PRINT "NOW I KNOW"
30 GOTO 10
Haha, this reminds me with the happy time with BASIC

I love BASIC more than C !
Dec 19 '07 #7
user1 wrote:
the constant 3.3 defaults to type double, use a cast

Print( (float) 3.3)
Or use a float constant to begin with:
Print(3.3f)
Dec 19 '07 #8
loudking wrote:
>Why do you think this code won't copile:

10 PRINT "DUH"
20 PRINT "NOW I KNOW"
30 GOTO 10

Haha, this reminds me with the happy time with BASIC

I love BASIC more than C !
In a way C has become rather like BASIC has always been. There is an
official ISO Standard that has almost no complete implementations, with
most of the code being written to a de facto Standard or in a mish mash
of various dialects.

Dec 19 '07 #9
ya********@gmail.com wrote:
Why won't this code compile?
#include <iostream.h>
^^^^^^^^^^
Because this is not a standard C (or C++) header?
void Print(int i);
void Print(float f, int skip = 0);
void main()
^^^^
Because main returns an int, and there is no excuse for this Schildtism?
{
Print(3.3);
}
void Print(int i)
{
cout << "Integer" << endl;
^^^^ ^^^^^^^ ^^^^
Because you are app;ying left-shift operators to undefined variables
(cout and endl) and to a string literal ("Integer")?
}
void Print(float f, int skip)
{
cout << "Float";
Because you are attempting to left shift an undefined variable (cout)
by something not an integral scalar?
if (skip != 0)
cout << endl;
Again.
}
If you cna't figure out what language you are attempting to misuse, then
it is no wonder that you can't write compilable code.
>
Dec 19 '07 #10

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

Similar topics

10
by: AlexS | last post by:
Hi, I wonder if anybody can comment if what I see is normal in FW 1.1 and how to avoid this. I have .Net assembly, which creates literally thousands of temporary strings and other objects...
11
by: Bo Peng | last post by:
Dear List, It is not clear what the title means. :-) Here is the details: I need to manage a big bunch of small objects, like struct{ int a; int b; }obj;
24
by: Salad | last post by:
Every now and then I see ads that state something like "Experience with Large Databases ...multi-gig...blah-de-blah" And I have to laugh. What's the difference between a large or small database? ...
17
by: Student | last post by:
Hi All, I have an assignment for my Programming language project to create a compiler that takes a C++ file as input and translate it into the C file. Here I have to take care of inheritance and...
32
by: David Isaac | last post by:
I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
3
by: Carter | last post by:
I am currently writing some code where I have a list of objects with a maximum occupancy of 4. I have been employing std::vector for this but I was wondering how much overhead is involved. Is it...
10
by: Hendrik Maryns | last post by:
Hi, Once again I’d like some feedback on the site http://www.weltladen-tuebingen.de. The situation is the following: I, as a real computer freak, have a Big Screen. The lady who is...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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,...
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
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,...
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...

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.