namespace Platform.

Why can't I use (String^) pointer in the class below while I can in the [Form1.h] class which that is used for designing components in VS2010 ?

-MSDN says that you can use it whenever you implement [Platform] namespace.

Error 1 error C2871: 'Platform' : a namespace with this name does not exist.

Error 2 error C2061: syntax error : identifier 'String'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "stdafx.h"

using namespace Platform;

MyFunctions::MyFunctions(void)
{
}

void MyFunctions::showMenu( String^ Query, String^ Message)
{
	SqlCommand^ cmd = gcnew SqlCommand(Query, connection);
        try
   {
	connection->Open();
	SqlDataReader^ reader = cmd->ExecuteReader();

	while(reader->Read())
	{
	String^ name = reader->GetString(reader->GetOrdinal("Name"));
	String^ price = reader->GetDouble(reader->GetOrdinal("Price")).ToString();
	ListViewItem^ item = gcnew ListViewItem (name);
         item->SubItems->Add(price);
         listView1->Items->Add(item);	
         }

    } catch(Exception^ e)
{
MessageBox::Show(Message);
}
    finally
   {
    connection->Close();
   }
}
Which of your file headers contain "Platform"? Maybe you forgot to include it or "Platform" was never a namespace in it(it must be any of the two or both). I'm confused: when has operator^ changed its uses from bitwise XOR to being a pointer to...?
According to what I understood from MSDN,
[http://msdn.microsoft.com/en-us/library/windows/apps/hh710417(v=vs.120).aspx]

The Platform namespace contains, attributes, classes, enumerations, interfaces, and structures.

I couldn't see any header file ( That's why I'm asking ).

and here's an example in the link below ..
[http://msdn.microsoft.com/en-us/library/windows/apps/hh699870(v=vs.120).aspx]

{ I'm new in C++ , I'd be grateful if you clarify a solution or things I don't know here :) }
Type^ is a WinAPI specific thing.
The header is vccorlib.h; you won't have it with VS2010.

To use C++/CX (WinRT), you need VS2012/13 and Windows 8.

To write a WinForms program with VS2010, see:
http://msdn.microsoft.com/en-us/library/ms229601(v=vs.100).aspx


> Type^ is a WinAPI specific thing.

No. ^ and ^% are C++/CLI extensions.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Last edited on
Thank you
Topic archived. No new replies allowed.