Re: classes, strings, learning in VS.NET

From: An Ony (nowhere_at_somewhere.net)
Date: 12/02/03


Date: Tue, 2 Dec 2003 12:03:42 +0100


> > I'm just learning c++ with the book from Bjarne Stroustrup and I just
type
> > what is in his book into Visual Studio .NET. Is that a good compiler for
> > that or not? I'm beginning to have my doubts... and it needs to be ANSI
C++
>
> It is a good Compiler, at least the 2003 version.
>
> > anyway, what's wrong with this:
> > =====================>
> > class Employee {
> > short dept;
> > public:
> > Employee();
>
> Here you declare that you will provide a constructor for your Employee
> class.
>
> Later, the linker informs you that it couldnt find one. So either remove
> this line and the compiler generates a Constructor automatically for you
> or keep your promise and implement it:
>
> Employee::Employee() {
> // Do whatever is useful here
> }
>
> > };
> >
> > void main(){
>
> int main() {
>
> void is not allowed for main.
>
> > Employee e = Employee();
>
> Looks weird. Why not simply:
>
> Employee e;
>
> > }
>
ah thanks, I'll go try it now. I'm used to program in Java so that's how I
thought it was logic. And that book said, "don't declare without
initialization", so isn't "Employee e;" kinda wrong?



Relevant Pages

  • Re: Linking error
    ... you declare that this class has a default ... so the compiler will not). ... > bool password() ... Here you *use* the default constructor of comp_network. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Object reference not set to an instance of an object
    ... Even if it can choose a constructor, ... > Are you saying that all OO compilers require us to both declare and then ... Is that really inherent in OO compiler design? ... >> really create an instance of TStrings since it has abstract methods? ...
    (alt.comp.lang.borland-delphi)
  • Re: Default constructor construction
    ... He states that a default constructor ... > is not ALWAYS generated by the compiler - ONLY when it's NEEDED and then he ... such terms as "declare" and "define" when it comes to providing implicit ...
    (comp.lang.cpp)
  • Re: Virtual Base Class Question
    ... >>>'A' doesn't have a default constructor. ... And since 'B' doesn't initialise ... >>>I believe the compiler complains because neither 'B' nor 'C' initialise ... compiler care *until the point* I actually came to declare a C or B????? ...
    (microsoft.public.vc.language)
  • Re: Factory Class Question
    ... move EmployeeFactory, Employee, Facilty1Employee, and Facilty2Employee all ... Facilty1Employee, and Facilty2Employee as Friend. ... > Facility2_Employee has an overloaded constructor which means I can't make ... >> instance of a class with a private constructor is rare, ...
    (microsoft.public.dotnet.languages.vb)