From -4976643511713533321
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,233d359668307510
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-03-14 08:17:28 PST
Path: bga.com!news.sprintlink.net!howland.reston.ans.net!agate!tcsi.tcs.com!uunet!athos.cc.bellcore.com!morris!rnn
From: rnn@morris.NoSubdomain.NoDomain (Rajesh Nihal)
Newsgroups: comp.std.c++
Subject: Re: A language feature or quirk ?
Date: 14 Mar 1995 16:09:54 GMT
Organization: Bell Communications Research
Lines: 25
Distribution: world
Message-ID: <3k4f4i$lqc@athos.cc.bellcore.com>
References: <3k2tn6$jig@mozo.cc.purdue.edu>
NNTP-Posting-Host: morris.bigcat.bellcore.com

In article <3k2tn6$jig@mozo.cc.purdue.edu>, kavuri@lips.ecn.purdue.edu (Surya N Kavuri ) writes:
|>  
|>  void Print(char *s) { cout << s; }
|>  
|> int main ()
|> {
|>   Print("Hello");  // compiles; not an error!
|>  
|>   const char* s = "Hello";
|>   Print(s); // Compile time error as expected!
|>   
|>   cout << "What on earth is going on ?" << endl;
|>   return 0;
|> }
|> 
|> 
|> 
|> 
|> Surya Kavuri

You need to cast the s to char*, since s is declared as const char* and
Print function takes its argument as char*. In C++ const char* do not
get automatically casted to char*.

Raj.


