473,785 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

"Anil Gupte/iCinema.com" <an*******@icin ema.comha scritto nel messaggio
news:%2******** **********@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
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************ ****@REMOVEMEgm ail.comwrote in message
news:Om******** ******@TK2MSFTN GP02.phx.gbl...
>
"Anil Gupte/iCinema.com" <an*******@icin ema.comha scritto nel messaggio
news:%2******** **********@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


Nov 4 '08 #3

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

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************ ****@REMOVEMEgm ail.comwrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
>
"Anil Gupte/iCinema.com" <an*******@icin ema.comha scritto nel messaggio
news:ur******** *****@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

Nov 4 '08 #5
"Anil Gupte/iCinema.com" <an*******@icin ema.comwrote in message
news:##******** ******@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
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*****@12fast mail34.fmwrote in message
news:uq******** ******@TK2MSFTN GP04.phx.gbl...
"Anil Gupte/iCinema.com" <an*******@icin ema.comwrote in message
news:##******** ******@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


Nov 5 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1577
by: Elger | last post by:
Dear Members, A newbie question How do I convert this XML example into HTML (using XSLT)? <DOCUMENT> <PARA> This <BOLD>is</BOLD> a <BOLD>test</BOLD> </PARA> </DOCUMENT>
4
1068
by: DragonLord | last post by:
I have a custom user control that i am trying to understand and it has numbers before the line items. So here it comes the real newbie question What the heck are the numbers for?? 205: For lngCount = 0 To lstIncluded.Items.Count - 1 206: If lstIncluded.GetSelected(lngCount) Then 207: strMembers = strMembers & VB6.GetItemData(lstIncluded, lngCount) & "," End If 209: Next 211: If Len(strMembers) > 0 Then 212: strMembers =...
5
2522
by: kamikaze04 | last post by:
Hello. I have a very newbie question about Streams. The situation is that i have a function (that i cannot modify it's definition/call): public void F1(istream & in){ while( ...) { in >> value do stuff with value; }
5
1148
by: Banibrata Dutta | last post by:
Hi, I've gone through the list of "language differences" between 2.3 / 2.4 & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of CPython, and I consider myself still very very newbie. So, unable to take a call as to how-important or desirable the newer language features are -- so whether to write my app for v2.5 of Python, versus, as few others on this list have recommended, i.e. to stick to v2.3 ?? Are the preformance...
16
1883
by: Raxit | last post by:
Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy in c++/java !? Tnx, Raxit
7
1515
by: idiolect | last post by:
Hi all - Sorry to plague you with another newbie question from a lurker. Hopefully, this will be simple. I have a list full of RGB pixel values read from an image. I want to test each RGB band value per pixel, and set it to something else if it meets or falls below a certain threshold - i.e., a Red value of 0 would be changed to 50. I've built my list by using a Python Image Library statement akin to the following:
5
2706
by: Randall | last post by:
I am a newbie trying to learn the DOM. Can someone tell me why the first alert statement returns null, and the second returns the value 33px (which was set using the style="top:33px;" in the DIV tag). Why doesn't the first alert statement pick up the style.left attribute from the CSS? <html> <head> <style type="text/css">
12
1857
by: Philipp.Weissenbacher | last post by:
Hi all! This is most certainly a total newbie question, but why doesn't the following code cause a segfault? void insertion_sort(int a, int length) { int i; for (i=0; i < length; i++) { int j, v = a;
3
2346
Lokean
by: Lokean | last post by:
Sorry for this newbie question, this is not my realm of expertese. I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to Oxygen, to HTML kit, et cetera. I am more confused than ever. here's my quandry. I was sent a file and told that we need to get the data into a more readable form. I've tried using apps to pull it in, but it's not displaying properly.
5
1399
by: Dave | last post by:
I am new to Visual Web Developer 2005 Expres. I am using absolute positioning and every time I add a button control to my web form its width extends all the way to the edge of the page. IOW I get a long skinny button that extends to the right side of the browser. This does not appear to happen with other controls. Any idea why it happens to the button? Here is how the button looks in source code:
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.