Search Results

Search found 1 results on 1 pages for 'user1435915'.

Page 1/1 | 1 

  • C++ data member initializer is not allowed

    - by user1435915
    I totally new to C++ so bear with me. I want to make a class with a static array, and access to this array from the main. Here is what i want to do in C#. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Class a = new Class(); Console.WriteLine(a.arr[1]); } } } ===================== namespace ConsoleApplication1 { class Class { public static string[] s_strHands = new string[]{"one","two","three"}; } } Here is what i have tried: // justfoolin.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> using namespace std; class Class { public: static string arr[3] = {"one", "two", "three"}; }; int _tmain(int argc, _TCHAR* argv[]) { Class x; cout << x.arr[2] << endl; return 0; } But i got: IntelliSense: data member initializer is not allowed

    Read the article

1