C++ :: IntelliSense - Expression Must Have Integral Or Unscoped Enum Type

Sep 6, 2014

So far I have the following code:

// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in
// in 5, 7, and 10 years.

# include <iostream>
# include <string>
using namespace std;
int main() {
float X = 10;
string Y="";

[Code] ....

But I get the following error message:

IntelliSense: expession must have integral or unscoped enum type

three times in a row for lines 25, 27, and 29 and I don't understand or know why?

In case the purpose does make sense here are the directions:

2.7: Ocean Levels

Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a program that displays

•The number of millimeters higher than the current level that the ocean’s level will be in 5 years,
•The number of millimeters higher than the current level that the ocean’s level will be in 7 years,
•The number of millimeters higher than the current level that the ocean’s level will be in 10 years,

Output labels:

Each value should be on a line by itself, preceded by the a label of the form:

In X years the ocean's level will be higher by Y millimeters.

where X is the number of years (5, 7 or 10) and Y is the value you calculate.

View 16 Replies


ADVERTISEMENT

C++ :: Error / Expression Must Have Integral Or Enumtype

Mar 19, 2013

Code:

#include <iostream>
#include <iomanip>
using namespace std;
//chose to use #define since columns/rows are a constant in the program
#define x 5
#define y 3
int main() {
//declare variables

[code]....

View 8 Replies View Related

C :: Enum - Incomplete Type Is Not Allowed

Sep 30, 2014

I have an enum like:

Code:
typedef enum mac_type_e{
STATIC_MAC,
BLACKLIST_MAC
} mac_type_t; and I want to use this type in a structure that's declared like:

Code:
typedef struct lan_mac_s {
UINT16 lanmacid;
enum mac_type_t lan_mac_type_pp;// user mac type per port, 20 mac_type_t array, 0 = static, 1 = blacklisted now,

The compiler tells me:

Code:
incomplete type is not allowed
enum mac_type_t lan_mac_type_pp;// user mac type per port, 20 mac_type_t array, 0 = static, 1 = blacklisted

But if I remove the preceeding "enum" keyword, it compiles fine.

View 2 Replies View Related

C/C++ :: Change Enum Type Variable To String Type Variable?

Aug 10, 2014

How to change an enum type variable to a string type variable?

View 2 Replies View Related

C++ :: Expression Must Have A Class Type?

Apr 3, 2014

I am making a program that allows you to add two big numbers that are larger then what int can handle together. I think I have done everything to accomplish this but when I try to instantiate the program I get a error Expression must have a class type.

Here is my main file that is supposed to instantiate the program.

Code: #include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <conio.h>
#include "LargeIntegers.h"
using namespace std;

[code]....

View 10 Replies View Related

C++ :: How To Find Expression Must Have Class Type

Oct 2, 2013

#include<iostream>
#include<math.h>
#include<string>
using namespace std;
class houseinfo{
private:
string name;
string address;

[Code] .....

View 2 Replies View Related

C++ :: Error / Expression Must Have A Class Type

Apr 15, 2015

I'm trying to learn recursion, and I'm using a simple array to experiment with it, but I have a couple of annoying errors that I don't understand why they're there. Here's the code:

Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int largest(const int arr[], int lowerIndex, int upperIndex) {
int max;

[code]....

Now try to print the array backwards:

//Use a recursive algorithm to find the largest element in arr:
int largest(arr[], lowerIndex, upperIndex);//error: expected an expression
return 0;
}

View 14 Replies View Related

C++ :: In What Type Intermediate Result Of Expression Is Stored

Jan 8, 2013

my doubt is :- in what data type the intermediate result of an expression is stored? like for expression 2+3*1/2 , i think the intermediate result for 1/2 is stored in the form 0.5 but for expression 2+3*1/100 , i think the intermediate result for 1/100 is stored in the form 0.01 so i am not sure if the compiler use dynamic type ie, changes with need. or it always stores in high precision like:- for 1/2 its 0.5000 and for 1/100 also 0.0100 or something like that.

View 4 Replies View Related

C Sharp :: Data Type Mismatch In Criteria Expression?

Feb 12, 2013

I am firing an insert query like this in C# to MS ACCESS 07 Database

var expiry = dateTimePicker1.Text;
 string instr = "insert into MST_QUOTATION values(";
instr += txtID.Text;

[Code]...

data type mismatch in criteria expression

View 2 Replies View Related

C# :: Intellisense Not Displaying All Element Property File

Jan 28, 2015

It's a shock to me seeing the partial display of variables being picked by intellisense. I am working in VS2013 environment. I have a project, in the project Settings file I created string variables of about 100 to be accessed across the files for the project, like this:

A example of thew variable it worked for

public static String TradeportAccordionSystemAdminInstitutionManagement = Settings.Default.[b]TradeportAccordionSystemAdminInstitutionManagement[/b];

An example of the variable it did not work for

public static String TradeportAccordionSystemAdminInstitution = Settings.Default.

So, does it mean that the Settings file has a limit of variables that should be declared in it?

View 2 Replies View Related

C :: How To Evaluate Double Integral

Oct 6, 2014

I am very new to programming and would like to know where to even start when evaluating a double integral. I wanted to evaluate this double integral: 6x^3 + y^2 +7x from 0 to 1 (for both).

View 1 Replies View Related

C :: Trapezoidal Approx Of An Integral

Aug 2, 2013

One of my last programs to write was to use the trapezoidal rule to approx. the definite integral defined in the program. It works, now i am looking for ways to improve this code, if there are any.

Code:
#include<stdlib.h>#include<stdio.h>
#include<math.h>
double integral (double x);
int main(void){

[Code] ....

the output is simple:

Code: ssma-imac:ENG-3211 ssma$ ./integralThe integral of x^2 Sin(x) dx from 1 to 5 is -18.953841

And yes this is a very good approximation of the actual integral.

View 9 Replies View Related

C++ :: Calculate Integral Using Rectangles

Feb 13, 2013

I have a function written to calculate an integral using rectangles. I get this error: 'cannot convert double to double (*) (double) in assignment'. But whenever I remove one of the doubles something is undeclared.

double rect_integral(double a, double b, int n, int f) {

double x;
double (* fx) (double);

double func_1 = 5*(pow(x,4))+3*(pow(x,2))-10*(x)+2;
double func_2 = pow(x,2)-10;

[Code] .....

View 3 Replies View Related

C++ :: Const Static Integral Members

Jan 16, 2014

I've been having a problem concerning the initialization of const static integral members with floating point calculations. I'll let his sample program do the explaining:

class Foo {
public :
Foo() {}
const static int samplerate = 44100;
const static unsigned short tempo = 120;

[Code].....

I know you can't initialize const static non-integral types on the same line on which they're declared, but I don't see why even an implicit cast to an integral type should be disallowed. I make my calculations using doubles, so I'm surprised that even though it should degenerate into an integer - it's still a problem for the compiler.

View 1 Replies View Related

C++ :: How To Use Templated Varadic Sequences And Integral Sequence Wrappers

Jul 15, 2013

I've been studying the heck out of the boost metafunction libraries. I understand a good deal of what things like varadic functions and integral sequence wrappers are, but I am having a hard time putting everything together to get working functions, such as performing arithmetic operations or functions like that of std::vector.

Here is an example of what I'm talking about:

// Sequences
template<typename T... N> struct seq;
template<typename T, T... N> struct seq_c;

// Integral constant wrapper
template<int T> struct int_

[Code] .....

My knowledge of all of this is pretty scattered and I've really been trying hard to put it all together. Is this correct? How can I apply this and use it to do more?

View 5 Replies View Related

C++ :: Class With Enum And Constructor

May 29, 2013

I really confused with constructor (default constructor and constructor with parameters)

I coded this problem

and I worked almost, but I stock in constructor

Code:
class Tier {
public:
enum TIER_MAKE

[Code] ....

This is tier class and I have to finish constructor in class car (for simple, I skip detail code) -red things are the parts from class Tier

Code: Car()
: make(NULL), passengers(0), fuelcap(0.0), efficiency(0.0), tier(Tier::nexen)
{ }

[Code] ....

And someone said default constructor part has to be this

Code:
car( Tier::TIER_MAKE p_tiermaker = Tier::nexen )

//after i skip
but default constructor should be no parameter...? isn't it?

View 1 Replies View Related

C++ :: Getting Error Using Enum In If Statement?

Jan 19, 2014

I'm trying to make a simple C++ program in which the user must try to guess a number, if they guess too high it says "too high" and if they guess too low it says "too low".

I also decided to add a feature which allows them to select how many tries they would like to guess the number. I tried to make "tries" type an enum so if the user could not pick an invalid number but for some reason i cannot use it in an if statement.

here is the code and i am getting the first error on line 27:

Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int guess;

[Code]....

View 7 Replies View Related

C++ ::  Using Enum Defined In Class

Apr 1, 2013

I am trying to write a game in C++ with SDL, and I have a class that allows me to handle events. The class is actually really simple: It takes the SDL_Event, then 2 variables from 2 different enum to determine for which Event and which Key should be checked, and then a variable that will be modified if the event happens. Here is the class

EventParser.h
#include "SDL.h"
#include "SDL_opengl.h"
template<class T>

[Code]...

As of yet the variable only changes if the Left key has been released, it will be extended if the error has been solved.

Then, in my main.cpp file I define the Event and the EventParser as

SDL_Event event;
EventParser<float> ep;

And in a loop, the parseEvent function is called like this:
ep.parseEvent(event, ep.KeyUp, ep.LEFT, &xVariable);

However I get a linker error (not the first one I got when programming this game)
error LNK2019: unresolved external symbol "public: void __thiscall EventParser<float>::parseEvent(union SDL_Event,enum EventParser<float>::EventType,enum EventParser<float>::KbdKey,float *)" (?parseEvent@?$EventParser@M@@QAEXTSDL_Event@@W4EventType@1@W4KbdKey@1@PAM@Z) referenced in function _SDL_mainC:UsersPrideRageDocumentsVisual Studio 2012ProjectsSDL_TestSDL_Testmain.objSDL_Template

View 6 Replies View Related

C++ :: Enum Across Files - Unresolved Error?

Feb 3, 2014

I defined

enum symbol {A, B, C};

in file A.h

and in file B.h, I #include "A.h" , but still get error of A , B and C unresolved when using them. WHy?

View 15 Replies View Related

C++ ::  switch Case With Enum Types

Jul 4, 2014

I'm trying to convert the enum type {PG, R, G, PG-13, etc.} to strings so i can use it in cout statement but no matter what i put inside switch(), the compiler keeps saying Error: expression must have integral or enum type. What am I doing wrong exactly?

Movie covert_rating(Movie r) {
switch (r) {
case PG:
return "PG";
break;
case R:
return "R";

[code]....

View 4 Replies View Related

C/C++ :: Convert Enum To Text String

Jan 25, 2015

I want to convert an enum to a text string.

enum BREED {YORKIE,CAIRN,DANDIE,SHETLAND,DOBERMAN,LAB};

View 4 Replies View Related

C++ :: Initializing Enum Member In Constructer

Jul 25, 2012

I am learning OOP Console Programming and i got some error in my code;

Here is my code

#include <iostream>
using namespace std;
enum ch {CD,DVD}
class disk {
private :
ch choice;
[Code] ....

I want to compare the enum variable to char c, and cout CD when user press 'c' and cout DVD when user press 'd'. I got error like this :

error : expected ')' before 'c' at first line after public

Note : I must use enum to store value.

View 7 Replies View Related

C++ :: Using A String / Enum To Access Int Matrix?

Apr 2, 2012

Any way to use a string to access a specific item in a matrix of int[X].

I have a program which uses enums as iterators to reference a large amount of data. To select an item in the matrix, the user will enter a string, which is also an enum, which also must serve as an iterator for something in the matrix. Here is a toybox example:

#include <iostream>
#include <string>
using namespace std;
enum NyNumbers { First, Second, Third, Forth, LAST_VALUE };
int main(int argc, char* argv[]) {
int Matrix[LAST_VALUE] = { 1, 3, 7, 12 };

[Code] .....

The idea is the user executes the program by typing "./RUN First" to print out the first element in the MyNumbers array, "./RUN Second" to access the second, and so on. I can't use static numbers for the iterator. (i.e., "./RUN 1") I must reference by enum/string.

When run, the output of this problem is thus:

====================================================================
user@debian$ ./RUN Second
Matrix[ atoi(Second) ]: 1
user@debian$
====================================================================

BTW, if I change line 12 to this

====================================================================
cout<<Matrix[ argv[1] ]<<"
";
====================================================================

The error message is this

====================================================================
user@debian$ make
g++ -g -Wall -ansi -pg -D_DEBUG_ Main.cpp -o exe
Main.cpp: In function `int main(int, char**)':
Main.cpp:12: error: invalid types `int[4][char*]' for array subscript
make: *** [exe] Error 1
user@debian$
====================================================================

Which isn't unexpected. How to input the enum as argv[1]?

View 2 Replies View Related

C :: How To Handle Enum Checks In Function Arguments

Aug 31, 2013

As we know in C there is no checking if values passed to a function that takes enum are correct, that is if they have been defined in this enum. Example from Enums in C | Occasionally sane ([code] tags don't work on my fx 18.0.1 this is why I put in on pb): [URL] ......

Here c - How to check if an enum variable is valid? - Stack Overflow they say that common convention is add check whether value passed as the parameter is not bigger than the maximum value in enum. But how about situations when enum is composed of numbers from 1-20 and then from 500-510?

View 4 Replies View Related

C++ :: Read In String From File And Convert It Into Enum?

Dec 2, 2013

I defined

enum boundaryType_t {inside, inlet, outlet, wall, periodic};

now I have file written like this:

inside outlet

I want my program read the file and when encounter any enum type, instead of treating it as a string, I want the program store it in memory as a enum value.

How can I do that?

string s;
ifs>>s;
s // how to convert it to enum???

View 5 Replies View Related

C++ :: Converting Enum To String And Vice Versa?

Feb 25, 2014

It is working:

#include <iostream>
#include <string>
#include <vector>
#include <map>
const int ENUM_NOT_FOUND = -1; const std::string NEW = " ";
enum Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};

[code]....

Ouput with GCC 4.8.1:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Name a day: Friday
day = Friday

But the problem is that whenever I define a new enum, I have to define the << and >> overloads for the new enum again. Isn't there a way to template that as well, so that the << and >> overload needs to be defined just once? My atttempt:

template<typename Enum>
std::ostream& operator << (std::ostream& os, Enum en) {
return os << EnumConversions<Enum>::toString (en);

[Code] .....

fails to compile. I guess the problem is Enum is not known at compile time, even though it should be deducible during run time? Error mentions ambiguous overload for operator>>.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved