469,903 Members | 1,760 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

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::GetFiles(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
www.keeninc.net
www.icinema.com
www.wizo.tv
Nov 4 '08 #1
6 3053

"Anil Gupte/iCinema.com" <an*******@icinema.comha scritto nel messaggio
news:%2******************@TK2MSFTNGP03.phx.gbl...
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<System::String ^^args)
{
Console::WriteLine(L"Hello World");

DirectoryInfo ^ di = gcnew DirectoryInfo(".");
array< String^ >^ files = Directory::GetFiles( 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
Nov 4 '08 #2
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
www.keeninc.net
www.icinema.com
www.wizo.tv
"Giovanni Dicanio" <gi****************@REMOVEMEgmail.comwrote in message
news:Om**************@TK2MSFTNGP02.phx.gbl...
>
"Anil Gupte/iCinema.com" <an*******@icinema.comha scritto nel messaggio
news:%2******************@TK2MSFTNGP03.phx.gbl...
>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<System::String ^^args)
{
Console::WriteLine(L"Hello World");

DirectoryInfo ^ di = gcnew DirectoryInfo(".");
array< String^ >^ files = Directory::GetFiles( 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


Nov 4 '08 #3

"Anil Gupte/iCinema.com" <an*******@icinema.comha scritto nel messaggio
news:ur*************@TK2MSFTNGP06.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

Nov 4 '08 #4
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
www.keeninc.net
www.icinema.com
www.wizo.tv
"Giovanni Dicanio" <gi****************@REMOVEMEgmail.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>
"Anil Gupte/iCinema.com" <an*******@icinema.comha scritto nel messaggio
news:ur*************@TK2MSFTNGP06.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

Nov 4 '08 #5
"Anil Gupte/iCinema.com" <an*******@icinema.comwrote in message
news:##**************@TK2MSFTNGP03.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
Nov 4 '08 #6
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
www.keeninc.net
www.icinema.com
www.wizo.tv
"Pavel A." <pa*****@12fastmail34.fmwrote in message
news:uq**************@TK2MSFTNGP04.phx.gbl...
"Anil Gupte/iCinema.com" <an*******@icinema.comwrote in message
news:##**************@TK2MSFTNGP03.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


Nov 5 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Elger | last post: by
16 posts views Thread by Raxit | last post: by
5 posts views Thread by Randall | last post: by
12 posts views Thread by Philipp.Weissenbacher | last post: by
5 posts views Thread by Dave | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.