473,382 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Why can't fixed arrays be in class?

I tried to put fixed array into class, but the C++ Compiler generates
an error as syntax error of '{'. I don't find anything wrong. Fixed
array is used to have a list of strings.

For example

class Test
{
public:
Test();
~Test();

private:
static const char List_Strings[5][10] =
{
"abc",
"def"
};
}
Aug 15 '08 #1
1 1119
In article
<28**********************************@y21g2000hsf. googlegroups.com>,
Immortal Nephi <Im************@satx.rr.comwrote:
[...]
class Test
{
public:
Test();
~Test();

private:
static const char List_Strings[5][10] =
{
"abc",
"def"
};
}
Only static constant integers can be initialized in the class; the rest
can be initialized only in the (separate) definition:

// Test.hpp
class Test
{
// Declaration only
static const char List_Strings[5][10];
}

// Test.cpp
// Definition and initialization
const char Test::List_Strings[5][10] =
{
"abc",
"def"
};
Aug 15 '08 #2

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

Similar topics

10
by: BadOmen | last post by:
I have made an array in a function in a Class now I need to get to that Array from an other function in an other Class, How do I do that? The Array has no fixed size as it is dependent on how...
4
by: Greg Baker | last post by:
I don't know what standard protocol is in this newsgroup. Am I allowed to post code and ask for help? I hope so.. :) Here's my problem: I am trying problem 127 of the valladolid online...
21
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
12
by: Linny | last post by:
Hi, I need some help in declaring an array of pointers to array of a certain fixed size. I want the pointers to point to arrays of fixed size only (should not work for variable sized arrays of the...
2
by: Chris Finlayson | last post by:
Hello: I have a question on pinning types via 'fixed'. In "Com and .NET interoperability" by Andrew Troelsen, he provides a simple example of ..NET -> Native interoperability: int...
2
by: coz | last post by:
I created a wrapper class for a dll written in C. Will the following code prevent the "ENTIRE ARRAY" from being moved, not just the first array element? The Wrapper class will be instantiated in...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
8
by: nickooooola | last post by:
Hello to all I'm about to write a simulator for a microcontroller in python (why python? because I love it!!!) but I have a problem. The registry of this processor are all 8 bit long (and 10...
5
by: bozzzza | last post by:
Consider: struct myStructA { public unsafe fixed byte pA; } struct myStructB { public unsafe fixed byte pB;
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.