Thread: newbie : a little confused ?

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    91

    newbie : a little confused ?

    hi !

    I am currently reading the book "Microsoft Visual C++ .NET Step by Step - Version 2003 Julian Templeman and Andy " and the guy has used visual studio 2003 for all his excercies......

    I am using Visual studio 2005 and the confusing part is that all the managed types he explains in visual studio 2003 fail in visual studio 2005 ..... the options are not the same also .....

    for eg. he talks about giving prefixes to classes like _gcl or _value which decide the how the garbage collection will take place by the .NET framework ...... I tried that in Visual studio 2005 and it tells me that its old code.....

    the guy tells to start a console appication but uses weired form here is a sample program :


    Code:
    // This is the main project file for VC++ application project 
    // generated using an Application Wizard.
    
    #include "stdafx.h"
    
    #using <mscorlib.dll>
    
    using namespace System;
    
    // The Point structure definition
    __value struct Point
    {
    public:
    	Point() { x = 0; y = 0; }
    	Point(int xVal, int yVal) { x = xVal; y = yVal; }
    
    	int x, y;
    };
    
    int _tmain()
    {
    	// Create a Point
    	Point p1;  // use the default constructor
    	Point p2(10,20);   // use the second constructor to set x 
    						// to 10 and y to 20
    
    	// Initialize its members
    	p1.x = 10;
    	p1.y = 20;
    
    	Console::Write(S"p1.x is ");
    	Console::WriteLine(p1.x);
    
    	return 0;
    }
    I get serious errors if I follow the managed C++ style .... what am I doing wrong or is this guy gone cuckoo ...... please help

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Much of MSVC++ 2003.net is much to do with the framework. I also own 2003 although I do not use it much. The code you posted does indeed look odd, why does main look like
    int _tmain()? Never seen that before!

    Only advise I can give is to stick with a more updated book, or press F1 when you highlight an error message in the compiler note box. That will tell you what the error means in a better lingo

    Thing is, where MSVC++2005 is more updated, some of the syntax that works with 2003 will be regarded as decepricated or "old". Microsoft update their software regually.
    Stick with the book if you want, but I would get a book that is less confusing, and main reads int main(), as you know it is more or less up to date - others might give you a better reply, hope I was of use to you..-pete

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    91
    so would working on Visual C++ .net 2003 solve my problem ...... because I can ask the lab guy to install the previous software ........ would this code work there ?

  4. #4
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    The book you are using appears to be teaching very
    implementation specific code - try running on a different compiler
    and it won't work - is that what you want? Generally its a better
    idea to learn the standardised code, then if you have a platform
    dependant task like programming with the Win API you can pick
    up the basics quicker.

    My guess is that it would work on that specific environment if
    that's what the book was written for
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    First remark: you are reading a book on managed C++. Managed C++ would best be described as C++.NET. It's the combination of a slightly limited but very easy Framework and a powerful but tricky language. You end up with a slightly limited Framework and a tricky to use language. Not the best thing for learning. It is very usefull for interfacing between C++ and .NET, but chances are you want something else. The power of pure C++ or the ease of C#.

    The code is implementation specific, because it's not ANSI C(++). Hardly surprising, it's C++.NET. As far as I know there is no other compiler for C++ with managed extensions, so it isn't really implementation specific per se but rather the only implementation there is. You won't get problems on other platforms or with other compilers, because they can't handle it anyway.

    From 2003 to 2005 the underlying .NET Framework went from 1.1 to 2.0 and the differences are great but sometimes codebreaking. Managed C++ changed to C++/CLI, a different name for the beast and some very nice changes to how the "tricky" stuff was handled. All in all good changes, but you'd want to get a recent book to actually learn what is currently used.

    _tmain is a UNICODE macro of VS. It might seem odd because there's no text yet, but keep in mind there will be command line parameters in other versions. _tmain will expand to either main or wmain depending on the characterset options you specify.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confused newbie
    By MWalden in forum C++ Programming
    Replies: 37
    Last Post: 06-26-2007, 09:46 AM
  2. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 12:13 PM
  3. newbie question about linked list
    By gemini_shooter in forum C Programming
    Replies: 10
    Last Post: 04-13-2005, 10:50 PM
  4. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  5. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM