473,386 Members | 1,763 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,386 software developers and data experts.

compiler error expected primary-expression before token

32
I have the following class, the primary-expression error takes place in the constructor before "{" token where the maskval[16] array gets initialized.

any help would be appreciated

emp1953
Expand|Select|Wrap|Line Numbers
  1. class encoderclass
  2. {
  3. public:
  4.  
  5.     //vars
  6.     long maskval[16];
  7.     float bitval[15];
  8.  
  9.     //methods
  10.     short encodeCosineData(float);
  11.     float decodeCosineData(int);
  12.     encoderclass()
  13.     {
  14.     maskval[16]= {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768};
  15.  
  16.     bitval[15]    = {(1/16000),
  17.                   (1/8000),
  18.                   (1/4000),
  19.                   (1/2000),
  20.                   (1/1000),
  21.                   (1/512),
  22.                   (1/256),
  23.                   (1/128),
  24.                   (1/64),
  25.                   (1/32),
  26.                   (1/16),
  27.                   (1/8),
  28.                   (1/4),
  29.                   (1/2),
  30.                   1 };
  31.     };
  32.  
  33.  
  34. private:
  35.  
  36. protected:
  37.  
  38. };
Dec 13 '07 #1
2 13046
weaknessforcats
9,208 Expert Mod 8TB
You have to remember that constructors do not construct objects. The compiler constructs the objects by allocating memory and intializing all of the data members and then calls your constructor so you can finish up any details not already completed.

The arrays you are initializing in the constructor already exist so you cannot use array initilization syntax on them. You will need change the value of each element explicitly.
Dec 13 '07 #2
emp
32
You have to remember that constructors do not construct objects. The compiler constructs the objects by allocating memory and intializing all of the data members and then calls your constructor so you can finish up any details not already completed.

The arrays you are initializing in the constructor already exist so you cannot use array initilization syntax on them. You will need change the value of each element explicitly.

Understood, and that's the fix, thanks a bunch

emp
Dec 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: andy.herrera | last post by:
I'm getting this Error Message. Expected ';' Please Select One: <form name="form1"> <<------------ Error is here. <select name="selectTrans" onChange="If (this.value == 'checkout')...
2
by: Tony Wilkinson | last post by:
Hi, As a complete novice to C# I have fallen at the first hurdle. Sad but true, I can't get 'Hello World' to work! I have downloaded the .net SDK etc and installed them on my workstation as...
7
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description:...
0
by: ee02iu | last post by:
a = 0; a = 0; a = 0; a = 0; are the results from the printf() in the following program using an old Borland C++ (V4.5) compiler. #include <stdio.h> int a = {0, 1, 2, 3, 4}; int main( ) {...
3
by: Jeff | last post by:
Im compiling code on Fedora and I get the following error: 202: error: expected `;' before 'itr' this is in a .h file which has no .cpp file: template < typename Tcharl, typename Tcharr >...
35
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
I'd really like to be able to constrain a generic type to System.Enum or, better, enum. But of course that results in "Compiler Error CS0702". So far I've been checking the type parameter at...
2
by: Peted | last post by:
Hi, im moving a project from vs2005 to vs 2008. is doing so i have come across a compiler error regarding partial classes that i dont understand if anyone can explain it to me please the...
2
by: Shaheen Kushan | last post by:
I desperately need help with this error, Compilation Error: Compiler Error Message: CS1002: ; expected Source Error: Line 71:...
1
by: Anu ms | last post by:
Whenever i am trying yo compile , getting the error as Compilation Error: Compiler Error Message: CS1002: ; expected but i am not able to locate the error in the code. Thank you in Advance...
1
by: rameshjumgam | last post by:
i am having in my code like std::list<T*>::const_iterator iter=lst.begin(); and i am getting error error: expected `;' before âiterâ /root/INCLUDE/cw/gdlist.h:140: error: âiterâ was...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.