POV-Ray : Newsgroups : povray.off-topic : Thinking about Languages again : Re: Thinking about Languages again Server Time
1 Oct 2024 15:21:54 EDT (-0400)
  Re: Thinking about Languages again  
From: Darren New
Date: 28 Mar 2008 21:11:51
Message: <47eda567$1@news.povray.org>
Chambers wrote:
> Darren New wrote:
>> You can't accidentally declare the function taking a float in the 
>> headers and an integer in the body and have mysterious type crashes at 
>> runtime in spite of your static typing.
> 
> C++ won't let you do that, either.

Really?

So if I have a class declared as

A.h:
  class A { int X; float Y; }

A.c:

void makeAlpha(A* alpha) {
   alpha.X = 27;
   alpha.Y = 82.3;
}

B.c:
void useAlpha() {
   A alpha;
   makeAlpha(&alpha);
   printf("%d\n", alpha.X);
}

And I compile A.c, then change A.h to put the member variables in the 
opposite order, then compile B.c, and link the results together, you're 
telling me the C++ standard tells me that shouldn't link?

I'm impressed.

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.