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


ADVERTISEMENT

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++ :: 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 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++ :: How To Initialize Static Member Of Class With Template And Type Of Nested Class

Oct 7, 2014

How to initialize a static member of a class with template, which type is related to a nested class?

This code works (without nested class):

#include<iostream>
using namespace std;
struct B{
B(){cout<<"here"<<endl;}
};
template<typename Z>

[Code] ,....

View 1 Replies View Related

C++ :: Declare Template Type Object Inside Template Type Class Definition

Oct 12, 2013

Let me put it into the code snippet:

/**
This class build the singleton design pattern.
Here you have full control over construction and deconstruction of the object.
*/
template<class T>
class Singleton

[Code]....

I am getting error at the assertion points when i call to the class as follows:

osgOpenCL::Context *cxt = osgOpenCL::Singleton<osgOpenCL::Context>::getPtr();

I tried commenting assertion statements and then the debugger just exits at the point where getPtr() is called.

View 7 Replies View Related

C++ :: Templated Class Function Does Not Have Class Type

Feb 3, 2013

I'm trying to template the return type for this function (component), I've looked around for example code but there doesn't seem to be any exactly like what I want.

Entity.hpp
class Entity {
public:
Entity();
unsigned int id = 0;
Component& addComponent(std::string);

[Code] ....

Error : 'ent1.component<HealthComponent>' does not have class type

View 2 Replies View Related

C++ :: Passing Class As Type In Template Class

Nov 30, 2013

I am trying to pass a class as a type to a template class. This class's constructor needs an argument but I cannot find the correct syntax. Is it possible?

Here is an example of what I described above. I did not compiled it, it is for illustrative purpose only. And of course argument val of the myData constructor would be doing something more useful than simply initializing an int....

template <class T>
class templateClass {
templateClass() {};

[Code]....

My real code would only compile is I add the myData constructor:

myData () {};

and gdb confirmed that it is this constructor that get called, even with dummy(4).

View 4 Replies View Related

C++ :: Return Value For A Type Class?

Apr 25, 2014

Code:
returnType operatorOperatorSymbol (parameterList); // syntax for operator overloading
Class Fraction

public:
Fraction operator-(const Fraction& f1){
Fraction r;
return r;
}

Is this even syntactically correct? It gives me errors. Im just trying to compile it without errors. I think the function makes sense since its returning a type Class

View 2 Replies View Related

C++ :: Function Non-class Type?

Jan 10, 2015

My g++ compiler is telling me that said printTest() is not part of the class. I have presented it in header class and implemented it in .cpp class but still keep getting the error. Compile and compile error -

blackjack > g++ -Wextra -pedantic -std=c++11 Deck.h Deck.cpp test.cpp ;
test.cpp: In function ‘int main()’:
test.cpp:6:6: error: request for member ‘printTest’ in ‘test’, which is of non-class type ‘Deck()’
test.printTest();

My Code -

//Deck.h
#include <iostream>
#include <string>
class Deck{
public:
Deck();
void printTest();

[code].....

View 3 Replies View Related

C++ :: Define A Class For A Type

Apr 29, 2014

Define a class for a type called CounterType. An object of this type is used to count things, so it records a count that is a non-negative whole number.

Include a mutator function that sets the counter to a count given as an argument. Include member functions to increase the count by one and to decrease the count by one. Be sure that no member function allows the value of the counter to become negative.Also, include a member function that returns the current count value and one that outputs the count. Embed your class definition in a test program and run sufficient tests to verify it all works correctly.

View 1 Replies View Related

C++ :: Error Class Does Not Name A Type

Nov 19, 2014

I am getting the error on the implementation of my class name. The error is coming from my parkingControl.cpp 'ParkingControl parkingControlMenu;'. I have used this implementation fine before, but once I added a new main it stopped working. Below is my code.

parkingControl.h
#ifndef PARKINGCONTROL_H_INCLUDED
#define PARKINGCONTROL_H_INCLUDED
#include <iostream>

[Code]....

View 2 Replies View Related

C/C++ :: Class Does Not Name A Type Error

Apr 6, 2015

I have two classes declared as below

#include<iostream>
using namespace std;
Class Node
{

[Code].....

View 4 Replies View Related

C++ :: List Class With Student Type?

Jul 3, 2013

I am trying to use a class Student and declare it as a list type. I can pushback but without changing the List.h or Node.h how can I print the data in list2?

Node.h
#ifndef NODE_H
#defineNODE_H
#include <string>

[Code].....

View 6 Replies View Related

C++ :: Initializing Array Of String Type In A Class

Apr 28, 2013

I want to use this array as part of my class. I have tried several different angles trying to get it to work but with out success. I have been checking to see if it works by simply using "cout << dayName[3];" It is printing nothing at all. What is the proper way to initialize this array of strings?

First I tried this:
const string dayName[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

then I tried this:
const string dayName[7];
dayName[0] = "Sunday";
dayName[1] = "Monday";
dayName[2] ="Tuesday";
dayName[3] ="Wednesday";
dayName[4] ="Thursday";
dayName[5] ="Friday";
dayName[6] ="Saturday";

My implemetation file code and my header file code is here (header first):

//dayType.h, the specification file for the class dayType
#include <iostream>
#include <string>
using namespace std;
class dayType{

[Code] .....

View 4 Replies View Related

C++ :: Changing Class Type Of A Vector Element?

Aug 16, 2014

I am programming a 2-D platformer video game. The stages are composed of an array (really a vector) of 16x16 px^2 tiles. I have defined a base class "Tile" and several derived classes, e.g., "Ramp", "Door", etc., which have their own attributes. The idea is that upon entering a room, the program will load all of the necessary tile data for that room into a vector. So, I have a vector that looks like: vector <Tile*> room_tiles, and resize it based on the total number of tiles in the room: room_tiles.resize(Tile_Count). I then want to read in certain info from the data file containing all of the tile information for that room. For example, if the data file says Tile 5 should be a ramp, I want to change the 5th element of the room_tiles vector to the derived ramp class. This is really where I'm having trouble. I've worked with vectors of base and derived classes before, but those were always of indeterminate size and I always used something like: (Vector).push_back(new DerivedClass()) to specify the derived class of that element. The problem is that that method only seems to work if you are appending elements to the end of a vector.

how I can do this?

View 7 Replies View Related

C++ :: Define A Class For A Type Called CounterType

Apr 29, 2014

Define a class for a type called CounterType. An object of this type is used to count things, so it records a count that is a non-negative whole number.

Include a mutator function that sets the counter to a count given as an argument. Include member functions to increase the count by one and to decrease the count by one.

Be sure that no member function allows the value of the counter to become negative.

Also, include a member function that returns the current count value and one that outputs the count. Embed your class definition in a test program and run sufficient tests to verify it all works correctly.

View 3 Replies View Related

C/C++ :: Stack Class For Generic Type Data

Feb 4, 2014

I'm trying to implement my own Stack class, for a generic data type. Here is what I have so far, but I'm having problems compiling the code:

Stack.h:
#ifndef STACK_H
#define STACK_H
#include <vector>
template< typename T >
class Stack {

[Code] .....

View 5 Replies View Related

C/C++ :: Pointer And Type Failure With Array In A Class

Mar 30, 2014

I am having trouble with the array pointer and with the variables. I don't seem to have the pointer set up because the additional times the array is called it is empty. Also, if I don't use integers the program drops through. where I am going wrong?

Question is in the code

/*
NumClass
Main.cpp
*******************************************************************************************
*
* Design a class that has an array of floating point numbers. The constructor should accept an integer argument and dynamically allocate the array to hold that many numbers. The destructor should free the memory held by the array. In addition, there should be member functions to perform the following operations:
*
**Store a number in any element in of the array

[code].....

View 1 Replies View Related

C++ :: Type Promotion Rules For Fixed Point Class

Jun 19, 2014

I've come across an interesting question involving a fixed-point arithmetic class.

Suppose I've got a template that implements a fixed-point quantity. It has two characteristics: width and number of fraction bits:

Code:
template <typename RAWTYPE, unsigned int FRACBITS>
class Fixed
{
....
};

So if I want a 32-bit value with 12 bits of fraction I can declare:

Code:
Fixed<int32_t, 12> x;

Suppose I've implemented a freestanding operator+() for fixed values, and I want to be able to add different types together:

Code:
template <typename RAWTYPE1, unsigned int FRACBITS1, typename RAWTYPE2, unsigned int FRACBITS2>
???? operator+(Fixed<RAWTYPE1, FRACBITS1> lhs, Fixed<RAWTYPE2, FRACBITS2> rhs)
{
???
}

What is the result type? Obviously, it's up to me to decide this. As reference, consider the type promotion rules for native types:

Code:
short a;
int b;
int result = a + b; In this case, the short value is promoted to the int value, and the addition happens on int.

It would seem a similar rule (go to the wider type) would be appropriate for fixed point. But there is another dimension to the problem, which is the number of fraction bits. Should you go to the wider type? Or the most precise type? Should you endeavor to minimize the number of bits which are discarded? What's the most intuitive rule?

View 10 Replies View Related

C++ :: Getting Type Alias From Template Class Without Specifying Arguments And Instantiating It

Feb 4, 2015

For example I want to get the type of std::vector<>::size_type without specifying a template argument.

Here's what I want to do:

std::vector<>::size_type x{5};

Is there any way this can be done?

View 4 Replies View Related

C++ :: Singleton Class - Auto Seems To Return Wrong Type

Jul 18, 2013

I am trying out a technique for a singleton class:

// access controlled singleton, accessed through function "instance()"
// singleton is constructed in this function
// so that constructor and destructor will be used
class single {
// private constructor/destructor

[Code] .....

Playing around with the code in main(), I am having trouble with auto:

single& s = single::instance(); // works fine
auto a = single::instance(); // error ~single() is private

When I make the destructor public, the output of the program is:

ctor
dtor
dtor

So I fixed this by typing auto&. I'm still confused though, why wouldn't auto know I am returning a reference?

View 2 Replies View Related

C++ :: Template Class Type - Unresolved Link Errors

Jun 25, 2013

I'm getting unresolved link errors when I attempt to compile.

dNode.h

#ifndef DNODE_H
#define DNODE_H
template <class T>
class dNode {

[Code] ....

ERROR:
Error1error LNK2019: unresolved external symbol "public: __thiscall dStack<double>::dStack<double>(void)" (??0?$dStack@N@@QAE@XZ) referenced in function "void __cdecl stack_test(void)" (?stack_test@@YAXXZ)main.objprog09
Error2error LNK2019: unresolved external symbol "public: virtual __thiscall dStack<double>::~dStack<double>(void)" .......

View 3 Replies View Related

C++ :: Initializing Static Map Of Variable Type Abstract Class?

Dec 3, 2014

A have two classes, one inheriting the other, and the parent class being abstract (I plan on adding more child classes in the future). For reasons I won't bother mentioning, I'm making use of an STL container as a way for me to access all of the child objects in the heap. I've done so by making use of a map, with key type int and value type being a pointer to the parent class:

//PARENT.H
class Parent {
protected:
static int n;
static std::map<int, Parent*> map;
public:
virtual void pureVirtual() = 0;

[code]....

The Problem:In line 5 of Parent.cpp, initializing the value of the element to new Child won't work, as according to the compiler, the Child class hasn't been declared yet, and including Child.h into the Parent.h only opens an even bigger can of worms.I also can't initialize it as new Parent, seeing as the parent class is an abstract one.

The Question:Is there a way I can initialize the static map properly. Making the Parent class abstract is not an option.

View 3 Replies View Related







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