error C2504: 'ostream_withassign' : base class undefined - c++

I am trying to learn C++ by practicing with exercises from the book but I seem to have run into yet another problem. I know the ostream_withassign class is found in the iostream library and that is included but I still do not understand what I am missing in my code still. I tried std but that does not seem to work either. Any one able to please inform me on what I am missing please. Thanks in Advance!
#include "stdafx.h"
#include "Conios.h"
class ConsoleStream :public ostream_withassign, public Conios
{
protected:
char X;
char Y;
public:
ConsoleStream(void);
ConsoleStream(std::streambuf * Buffer);
void SetX(char XX);
void SetY(char YY);
ConsoleStream &operator =(std::ostream &Out);
~ConsoleStream(void);
};

Your book must be very old (in computing terms). The ostream_withassign class was a nonstandard type available in "iostream.h" back in Visual Studio 6.0. You should probably update your reference material and use something more modern as many, many things have changed in C++ since then (c. 1998). (The most recent updates were standardized this year, in fact.)

Related

LLVM IR OOP inheritance implementation through C++ API

so I'm trying to write down a compiler for an OOP language with a syntax very similar to Java, and I'm stuck at figuring out how inheritance could be implemented.
What I've tried out already is writing a rather basic C++ inheritance example and compiling it with clang -S ${FILES} -emit-llvm.
The C++ code is the following :
a.hpp:
class A {
protected:
int a;
};
b.hpp:
#include "a.hpp"
class B : public A {
private:
int b;
public:
explicit B();
};
b.cpp:
#include "b.hpp"
B::B() : A() {}
main.cpp:
#include "b.hpp"
int main() {
B b;
}
But I honestly find the output to be really confusing indeed...
What I've discovered Googling is that in order to handle virtual methods and overrides I'll have to use vtables (and about that, knowing that I already found this tutorial in the LLVM doc but I didn't find it really helpful, is there a standard way of creating vtables in LLVM)?
I also have quite some doubts about the compilation order...
Let's say I have this source code :
package test;
class Test extends SuperTest {}
Seems pretty clear to me that in order to merge logical and data structures of Test and SuperTest while analyzing Test, SuperTest must have been compiled already, but how do I arrange the compilation such that problems like this cannot arise?
Thanks for the attention.

Undeclared identifier error c++, What did I do wrong i have no clue?

I am getting this error when ever i run this project
6 error C2065: 'Engine_in':undeclared identifier
I really dont know what i have done wrong. Usually i can figure it out and know what i did wrong but the books i have dont go into depth on seperate file classes. I honestly do not know where the error is coming from. I have googled it but everyones problems are specific, so that is why i am resorting to asking you to solve my problems. I appologize in advance for me not knowing much.
I have this class 'Engine_debug.cpp'
//Engine Debugger
#include<iostream>
#include "Engine_debug.h"
#include "Engine_in.h"
using namespace std;
Engine_debug::Engine_debug()
{
Engine_in input;
}
Then i have this header 'engine_debug.h'
#ifndef Engine_debug_H
#define Engine_debug_H
class Engine_debug
{
public:
Engine_debug();
protected:
private:
}
#endif
I also have this class 'Engine_in.cpp'
//Engine input
#include<iostream>
#include<string>
#include "Engine_in.h"
using namespace std;
Engine_in::Engine_in()
{
}
string askYN(string question, int format)
{...working code}
And one more, the other header 'Engine_in.h'
#ifndef Engine_in_H
#define Engine_in_H
class Engine_in
{
public:
Engine_in();
std::string askYN(std::string question, int format = 0);
protected:
private:
};
#endif
If anyone knows what i did wrong and would like to explain to me, please do, thanks.
If it isn't a typo, you forgot to write class name while defining the member function.
string Engine_in::askYN(string question, int format)
// ^^^^^^^^^^ Missed during member function definition
Not sure if that causes the kind of error message the compiler is complaining about.
There is also a missing ; at the end of Engine_debug class definition. Credits Jesse.

C++ class declaration error in XCode

I am porting a C++ project to Mac using Xcode. Now I have a class that is declared as following:
namespace poi {
class AesCipher : public SymetricCipher {
public:
AesCipher();
virtual ~AesCipher ();
//more method declarations here...
};
}
Yet Xcode will present me an error for the line of the public: statement:
C++ requires a type specifier for all declarations
I assume this has to do with the namespace but I'm not that experienced with C++.
I have no idea what this error is trying to say to me. Maybe someone has seen such an error before and could just point me in the right direction what kind of mistake I might have made.

Error when inheriting from a template class with multiple parameters

Goal: To inherit from a class with 2 template parameters.
Error
Error error C2143: syntax error : missing ',' before '<'
The Code
template< typename Type >
class AssetManager : public IsDerivedFromBase< Type, Asset* >
{
// Class specific code here
};
Things you need to know: Asset is a class that just wraps a char* with a getter/setter and IsDerivedFromBase will be used to basically test wether or not Type is a derivative of Asset. These sets of classes are isolated in there own small scale visual Studio 2012 project and will be integrated into the main project once all the functionality has been tested thoroughly.
Some Edits based on Comments
Thank you for the help so far, I really appreciate it. Here are some more specifics:
IsDerivedFromBase.h
#ifndef ISDERIVEDFROMBASE_H
#define ISDERIVEDFROMBASE_H
#include< iostream > // For access to NULL
namespace Fenrir
{
template< typename Type, typename Base >
class IsDerivedFromBase
{
private:
static void Constraints( Type* _inheritedType )
{
Base* temp = NULL;
// Should throw compiler error if
// this assignment is not possible.
temp = _inheritedType;
}
protected:
IsDerivedFromBase( ) { void( *test )( Type* ) = Constraints; }
};
}
#endif
Note: This class was based off of a class I read about in an article. I have since found a better way to achieve the desired result; however, I wish to understand where this error is stemming from.
AssetManager.h"
#ifndef ASSETMANAGER_H
#define ASSETMANAGER_H
#include "IsDerivedFromBase.h"
namespace Fenrir
{
template< typename Type >
class AssetManager : public IsDerivedFromBase< Type, Asset* >
{
// Class specific code
};
}
#endif
Keeping class specific code to a minimum to keep this post as neat as possible, if more info is needed just let me know and I can add it in :).
That error message is common when the compiler encounters an identifier that it did not expect, so a first guess would be that IsDerivedFromBase is not known to the compiler at the time (maybe you did not include the appropriate header?). Alternatively, if IsDerivedFromBase is not a template, the compiler would also expect a , (or ;) after it.
Solved my issue which was interestingly silly. So due to a comment (from Jesse Good) I took a quick look at my includes. Since this was a small "whip it up quick" kind of project I didn't really pay much attention to them. I don't know exactly where the error was occuring, but I found out that AssetManager did not know about IsDerivedFromBase so I set up the following code block to just solve that issue without having to write a bunch of
#include statements everywhere!
// Contact point houses all of the include files
// for this project to keep everything in one place.
#ifndef CONTACTPOINT_H
#define CONTACTPOINT_H
#include "Asset.h"
#include "Sprite.h"
#include "IsDerivedFromBase.h"
#include "GenericManager.h"
#include "AssetManager.h"
#endif
Now I just include this in every header and all is well. I've been programming C++ for a little over a year now and never ran into this, a good lesson to learn for anyone new programming.
Thanks for your help everyone : )

Visual Studio 2010 compile error with std::string?

So this is possibly the strangest thing I've seen recently and was curious how this could happen. The compiler gave me an error saying that std::string is undefined when used as a return type but not when used as a parameter in methods of a class!
#pragma once
#include <string>
#include <vector>
// forward declarations
class CLocalReference;
class CResultSetHandle;
class MyClass
{
public:
MyClass() {}
~MyClass {}
void Retrieve(const CLocalReference& id, CResultSetHandle& rsh, std::string& item); // this is fine
const std::string Retrieve(const CLocalReference& id, CResultSetHandle& rsh); // this fails with std::string is undefined?!?!
};
Doing a Rebuild All it still happened I had to choose clean solution and then Rebuild All again after for the universe to realign. While it's resolved for the moment I'd still like to know what could have caused this because I'm at a loss as to why when there should be no conflicts especially when I always use fully qualified names for STL.
This is probably a compiler bug. I have seen several others in VS2010.