Newbie Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anil Gupte/iCinema.com

    #1

    Newbie Question

    I am very new to C++ (Actually have dabbled in it before but nevermind).
    This is my first appliccation that I started from scratch. I created a
    Console Application in VC 2005 and this is what I have so far:
    using namespace System;

    using namespace System::IO;

    #include "stdafx.h"

    int _tmain(int argc, _TCHAR* argv[])

    {

    DirectoryInfo* di = new DirectoryInfo(" .");

    String* files[] = Directory::GetF iles(di->ToString()];

    return 0;

    }

    When I compile I get lots of errors. Even if I comment out the String*
    files line I get at least three errors. Here they are:

    Error 1 error C2065: 'DirectoryInfo' : undeclared identifier
    Error 2 error C2065: 'di' : undeclared identifier
    Error 3 error C2061: syntax error : identifier 'DirectoryInfo'
    Error 4 error C2065: 'String' : undeclared identifier
    Error 5 error C2065: 'files' : undeclared identifier
    Error 6 error C2059: syntax error : ']'
    Error 7 error C2653: 'Directory' : is not a class or namespace name


    Any help appreciated. Thanx in advance.
    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

    www.icinema.com



  • Giovanni Dicanio

    #2
    Re: Newbie Question


    "Anil Gupte/iCinema.com" <anil-list@icinema.co mha scritto nel messaggio
    news:%23%23vddC lPJHA.2720@TK2M SFTNGP03.phx.gb l...
    This is my first appliccation that I started from scratch. I created a
    Console Application in VC 2005 and this is what I have so far:
    [...]
    When I compile I get lots of errors.
    This code compiles fine for me:

    <code>

    #include "stdafx.h"

    using namespace System;
    using namespace System::IO;

    int main(array<Syst em::String ^^args)
    {
    Console::WriteL ine(L"Hello World");

    DirectoryInfo ^ di = gcnew DirectoryInfo(" .");
    array< String^ >^ files = Directory::GetF iles( di->ToString() );

    return 0;
    }

    </code>

    Note that to use the .NET Framework classes from C++, you should use C++/CLI
    extensions of the C++ language.
    In this case, instead of native pointers (*), you should have managed
    references (^), instead of 'new' you should use 'gcnew', etc.

    Giovanni


    Comment

    • Anil Gupte/iCinema.com

      #3
      Re: Newbie Question

      Ok that was completely Italian to me. Just joking, no offence. :-)

      Anyway, I copy-pasted your code and still gives me lots of errors.
      Error 1 error C2065: 'array' : undeclared identifier
      Error 2 error C2653: 'System' : is not a class or namespace name
      Error 3 error C2065: 'String' : undeclared identifier
      Error 4 error C2059: syntax error : '>'
      Error 5 error C2143: syntax error : missing ';' before '{'
      Error 6 error C2447: '{' : missing function header (old-style formal list?)

      But where can I read more about use CLI extensions and managed references?

      Thanx,
      --
      Anil Gupte
      Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

      www.icinema.com

      "Giovanni Dicanio" <giovanniDOTdic anio@REMOVEMEgm ail.comwrote in message
      news:OmwKAnlPJH A.1164@TK2MSFTN GP02.phx.gbl...
      >
      "Anil Gupte/iCinema.com" <anil-list@icinema.co mha scritto nel messaggio
      news:%23%23vddC lPJHA.2720@TK2M SFTNGP03.phx.gb l...
      >
      >This is my first appliccation that I started from scratch. I created a
      >Console Application in VC 2005 and this is what I have so far:
      [...]
      >When I compile I get lots of errors.
      >
      This code compiles fine for me:
      >
      <code>
      >
      #include "stdafx.h"
      >
      using namespace System;
      using namespace System::IO;
      >
      int main(array<Syst em::String ^^args)
      {
      Console::WriteL ine(L"Hello World");
      >
      DirectoryInfo ^ di = gcnew DirectoryInfo(" .");
      array< String^ >^ files = Directory::GetF iles( di->ToString() );
      >
      return 0;
      }
      >
      </code>
      >
      Note that to use the .NET Framework classes from C++, you should use
      C++/CLI extensions of the C++ language.
      In this case, instead of native pointers (*), you should have managed
      references (^), instead of 'new' you should use 'gcnew', etc.
      >
      Giovanni
      >
      >

      Comment

      • Giovanni Dicanio

        #4
        Re: Newbie Question


        "Anil Gupte/iCinema.com" <anil-list@icinema.co mha scritto nel messaggio
        news:urVMJ4lPJH A.576@TK2MSFTNG P06.phx.gbl...
        I copy-pasted your code and still gives me lots of errors.
        Error 1 error C2065: 'array' : undeclared identifier
        Error 2 error C2653: 'System' : is not a class or namespace name
        Error 3 error C2065: 'String' : undeclared identifier
        Error 4 error C2059: syntax error : '>'
        Error 5 error C2143: syntax error : missing ';' before '{'
        Error 6 error C2447: '{' : missing function header (old-style formal
        list?)
        You can start creating a new C++/CLI project with Visual Studio 2008 using
        this sequence:

        New Project | Visual C++ | CLR | CLR Console Application

        And you can copy-and-paste the code I posted there.

        (Before posting that code, I built it on my VS2008 IDE.)
        But where can I read more about use CLI extensions and managed references?
        Nish wrote a book about that topic:

        http://www.amazon.com/CLI-Action-Man.../dp/1932394818

        He masters the C++/CLI extensions, and I think that you can find interesting
        information on his blogs and his CodeProject articles, too.

        I hope that my "Italglish" is clear enough... ;)

        Giovanni



        Comment

        • Anil Gupte/iCinema.com

          #5
          Re: Newbie Question

          Thanx! Your english is very clear. I had trouble understanding the
          technical stuff. Thanx for your help, I will do some reading on this.

          --
          Anil Gupte
          Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

          www.icinema.com

          "Giovanni Dicanio" <giovanniDOTdic anio@REMOVEMEgm ail.comwrote in message
          news:%23h8UI%23 lPJHA.4760@TK2M SFTNGP02.phx.gb l...
          >
          "Anil Gupte/iCinema.com" <anil-list@icinema.co mha scritto nel messaggio
          news:urVMJ4lPJH A.576@TK2MSFTNG P06.phx.gbl...
          >
          >I copy-pasted your code and still gives me lots of errors.
          >Error 1 error C2065: 'array' : undeclared identifier
          >Error 2 error C2653: 'System' : is not a class or namespace name
          >Error 3 error C2065: 'String' : undeclared identifier
          >Error 4 error C2059: syntax error : '>'
          >Error 5 error C2143: syntax error : missing ';' before '{'
          >Error 6 error C2447: '{' : missing function header (old-style formal
          >list?)
          >
          You can start creating a new C++/CLI project with Visual Studio 2008 using
          this sequence:
          >
          New Project | Visual C++ | CLR | CLR Console Application
          >
          And you can copy-and-paste the code I posted there.
          >
          (Before posting that code, I built it on my VS2008 IDE.)
          >
          >But where can I read more about use CLI extensions and managed
          >references?
          >
          Nish wrote a book about that topic:
          >
          http://www.amazon.com/CLI-Action-Man.../dp/1932394818
          >
          He masters the C++/CLI extensions, and I think that you can find
          interesting information on his blogs and his CodeProject articles, too.
          >
          I hope that my "Italglish" is clear enough... ;)
          >
          Giovanni
          >
          >
          >

          Comment

          • Pavel A.

            #6
            Re: Newbie Question

            "Anil Gupte/iCinema.com" <anil-list@icinema.co mwrote in message
            news:##vddClPJH A.2720@TK2MSFTN GP03.phx.gbl...
            I am very new to C++ (Actually have dabbled in it before but nevermind).
            This is my first appliccation that I started from scratch.
            That's already wrong. Being very new in something, you start from samples,
            not from scratch. And there's lots of samples in the VS and MSDN site.

            --PA


            Comment

            • Anil Gupte/iCinema.com

              #7
              Re: Newbie Question

              Yeah, I have done stuff with samples and tuorials, but this was my first try
              at doing a blank sheet. Maybe I will revert to using an example as a
              template.

              Thanx,
              --
              Anil Gupte
              Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

              www.icinema.com

              "Pavel A." <pavel_a@12fast mail34.fmwrote in message
              news:uqJrjWsPJH A.4152@TK2MSFTN GP04.phx.gbl...
              "Anil Gupte/iCinema.com" <anil-list@icinema.co mwrote in message
              news:##vddClPJH A.2720@TK2MSFTN GP03.phx.gbl...
              >I am very new to C++ (Actually have dabbled in it before but nevermind).
              >This is my first appliccation that I started from scratch.
              >
              That's already wrong. Being very new in something, you start from samples,
              not from scratch. And there's lots of samples in the VS and MSDN site.
              >
              --PA
              >
              >

              Comment

              Working...