473,842 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compiler error expected primary-expression before token

32 New Member
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 13068
weaknessforcats
9,208 Recognized Expert Moderator Expert
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 New Member
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
5222
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') window.location.href='CheckOut.php';"> <option>---Please Select One ---</option> <option value="checkout">Check OUT</option> <option value="checkin">Check IN</option> </select>
2
1860
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 per Microsoft instructions.. I have written the usual 'Hello World' .cs file and then tried to compile it. I have used the following versions of the commandline syntax to try
7
12895
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
0
955
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( ) { int *p; for (p = a+4; p >= a; p--) printf ("a = %d;\t", (p-a), a);
3
3404
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 > inline std::basic_string<Tcharl>& CR_String::StrCpy ( std::basic_string<Tcharl&dest, const std::basic_string<Tcharr> &src )
35
2920
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 runtime and throwing an exception if the provided type is not an enum. That works, but it just doesn't seem quite right. After reading through section 4.4.4 of the C# 3.0 spec I see no reason why constraining to System.Enum should not be allowed.
2
2131
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 orig defintion that compiles and runs fine in vs2005 is bellow......
2
4014
by: Shaheen Kushan | last post by:
I desperately need help with this error, Compilation Error: Compiler Error Message: CS1002: ; expected Source Error: Line 71: //"----------------------------------------------------------------------" Line 72: //" -- Declare Variables" Line 73: Dim objConn
1
1838
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
3316
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 not declared in this scope /root/INCLUDE/cw/gdlist.h:142: error: âiterâ was not declared in this scope
0
9876
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10952
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
10618
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...
0
9459
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7045
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();...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4506
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4096
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3148
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.