473,382 Members | 1,387 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.

While I use switch case in parameterized constructor I get an warning..

while i compile my code i got an warning that,
"FUNCTIONS CONTAINS SWITCH ARE NOT EXPAND INLINE."

Basically I am writing switch case in the parameterized constructor at that time i get this warning.

Because of this error sometimes I can run the code and sometimes not.

I want to know can i write switch case in parameterized constructor?If yes,then how?
Nov 12 '13 #1
1 1273
Banfa
9,065 Expert Mod 8TB
Well I tried this

Expand|Select|Wrap|Line Numbers
  1. class Example
  2. {
  3. public:
  4.   Example(int a) :
  5.    data(a)
  6.   {
  7.     switch(a)
  8.     {
  9.     case 0:
  10.       cout << "Special Case 0" << endl;
  11.       break;
  12.  
  13.     case 1:
  14.       cout << "Special Case 1" << endl;
  15.       break;
  16.  
  17.     default:
  18.       cout << "Default Case " << a << endl;
  19.       break;
  20.     }
  21.   }
  22.  
  23.   ~Example()
  24.   {
  25.     cout << "Destroy " << data << endl;
  26.   }
  27.  
  28. private:
  29.   int data;
  30. };
Which compiled and ran without warning or error so you probably need to be more specific about what you are doing and what platform you are doing it on.
Nov 12 '13 #2

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

Similar topics

2
by: Daniel Fortin | last post by:
Hi, I was wondering if anyone knows how to overload operator new to use a parameterized constructor. Something like this: class class1 { public: class1(); class1(int parameter1);
15
by: YitzHandel | last post by:
The following is an extract from my program, which I seperated out and compiled as its own program. The problem is that as soon as a case tests true, all the cases below it execute as well. So...
10
by: Chih-Hsu Yen | last post by:
I encountered a strange problem about switch-case statement. switch(cmd) { case 1: statements; break; case 2: statements; break; ... .... case 11: S1; S2; S3; statements;
1
by: Peter | last post by:
Hi, When I update/add a new web reference to a web service class with a parameterized constructor, what is preventing the generated proxy from including a definition for the parameterized...
5
by: sam_cit | last post by:
Hi Everyone, I read somewhere that there are some compile time operations behind switch-case, which is why it can work for cases which evaluates to an integer or character and not strings and...
5
by: Sathyaish | last post by:
/* I am writing this C# program because I forgot the syntax for calling a parameterized constructor from a non-parameterized one within the same class. I was coding in Java and just typed it...
5
by: DaemonCoder | last post by:
I have a switch/case statement using numerics for a menu, but when i enter an alphanumeric statment it goes into a loop printing my menu and the default statement from switch/case the default...
4
by: Anuja T` | last post by:
Hi All, i have a test class.It allows exactly one zero-argument constructor. i have another performancetest class,in which i have to pass the respective method name for its performance testing....
1
by: monalijoshi | last post by:
Hi, As i have one Abstract base class say MyBase. It have parameterized constructor with string value it have abstract method call. And I also have One child class say MyChild. It does not have...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.