C++ :: Defining Function Prototypes In Header File Without Implemented Body

Oct 6, 2014

Basically, I have made a program which implements the platform specific layers (such as entry function, file loading, timing functions etc.) that gets compiled into a .exe (or platform equivalent).

But I want to make this portable and reusable across other projects, so the entry function for the platform will call the function "AppMain" which is the generic main function that is not reliant on the underlying platform etc. (i.e defined in a .h file that the project module will implement).

Ideally I would want to build the AppMain code into its own library. However, This AppMain code would want access to the Platform functions such as the functions compiled into the .exe.

This has confused me somewhat and has forced me to build both the AppMain module and the Platform Code into the same exe file so they can use each others functions.

Is there any way I can create a header file (with all the function prototypes in) but they do not get implemented in the Platform code but rather they can be 'guaranteed' to be available at runtime?

Here is what I am trying to achieve in a high level view:

win32layer.cpp: (implements all the functions defined in Platform.h)

#include <AppMain.h>
int main(int argc, char** argv) {
//call AppMain
return AppMain(argc, argv);

[Code] ....

in this scenario of course I could not compile the platform functions as the application has not been created and thus appmain cannot call the platform functions because that has not been created etc....

Any way to overcome this?

View 9 Replies


ADVERTISEMENT

C++ :: Defining Vector In Header File?

Feb 17, 2012

Suppose I have the following sample header file test.h

Code:
#include "myCommon.h"
class Test {
public:
Test();
vector<vector<vector<double>>> vI3(dim1, vector<vector<double>> (dim2, vector<double> (dim2, 0.0f)));
private:
fillVector();
}

In above test.h dim1 and dim2 are defined in a different header file, i.e. myCommon.h

Code:
const long dim1 = 40;
enum dimVector {
RED,
GREEN,
dim2
};

However, it gives the errors when I compile: variable "dim1" is not a type name and for variable "dim2" it complains about a duplicate parameter name.

The declarations of dim1 and dim2 should stay in myCommon.h. They can also be defined in myCommon.cpp if needed, but can't go into test.h.

View 3 Replies View Related

C/C++ :: Defining Member Function In Different CPP File

Mar 27, 2014

I am work on building a simple parse tree and the layout of my code look like this:

Headers
pt_node.hiterator.hparsetree.h

Source files
node.cppparsetree.cppmain.cpp

I am still relatively new to C++ , and have been advised to include function definition for the member function of both pt_node class and iterator class in the node.cpp file

I particular I have declare the following iterator.h:

inline bool operator ==(const tree_iterator& rhs);

which is defined in node.cpp as:

inline bool tree_iterator::operator==(const tree_iterator& rhs) {
return (node ==rhs.node);
}

However on building I receive the following error:

undefined reference to `dnkmat001::tree_iterator::operator==(dnkmat001::tree_iterator const&)'

Why is this occurring and what measure can I take to fix my code

View 14 Replies View Related

C++ :: Valid Function Prototypes?

Mar 11, 2013

I was asked by a friend about validity of following function prototypes,

void func1(int = 0, int*);
void func2(int = 1, int& = 2);
void func3(int*, int& = 3);
void func4(int& = 4, int* = 0);
void func5(int& = 0, int = 1);
void func6(int = 5, int& = 6, int* = 0);

I think the only prototype that is invalid is func1 because it does not have default parameter on the far right.

View 16 Replies View Related

C++ :: Member Function Prototypes Not Supported

May 4, 2013

I am working with a limited compiler (information you may need to know, I don't really know) and I made this function

Code:
void Swap(int &a , int &b); {
Destination temp;
temp = list[a];
list[a] = list[b];
list[b] = temp;
}

In the private part of a class and it is giving me the error "Member function prototypes not supported". How do I fix this and what is a member function prototype exactly?

View 3 Replies View Related

C++ :: Function Prototypes - Undeclared Identifier

Feb 17, 2013

Why "Team" and "NUM_MEMBERS" are undeclared identifiers? I'm not sure I understand why it's giving me errors for those.

//Function Prototypes
void initialize (vector <Team> & tV, const int ID [],
const string m[][NUM_MEMBERS], int arraySize);
void printList (const vector <Team> & tV);
void menu ();
void add (vector <Team> &tV);
int search (const vector <Team> &tV, unsigned int size, int ID);

View 3 Replies View Related

C++ :: Class Definition Inside Function Body

Mar 3, 2013

Is this standard-compliant code?

int f() {
class C {
public:
int mf() const {return 1;}
};
C c;
return c.mf();
}

View 1 Replies View Related

C++ :: Include Function From Header File?

Feb 21, 2013

I am trying to include a function from a header file named headerfunt.h . The code of my header file is

Code:
#ifndef HEADERFUNCT_H_INCLUDED
#define HEADERFUNCT_H_INCLUDED
#include <iostream>

[Code]....

But, while compiling it says abs was not declared... I have included the file.

View 2 Replies View Related

C :: Struct Array To Function On Header File?

Mar 13, 2014

I just can't make my code work. I need to pass a struct to a .h file. Here is my main:

Code:
#include "calculos.h"
#include "auxiliar.h"
struct dados{
int idade;

[Code].....

View 6 Replies View Related

C++ :: Complete List Of Useful Function In Header File

Dec 31, 2014

i want to know about dunctions in windows.h header file.i know some of it...like

sleep()
beep()

complete list of usefull functions in said header file.

View 2 Replies View Related

C++ :: Finding Function Documentation For Header File

Nov 23, 2013

I would like to see what functions the following header file has:

#include <tf/LinearMath/Transform.h>

Any website that has all the c++ libraries and where to find the functions that come with this?

View 4 Replies View Related

C++ :: Header File - Running Class Function As A Thread

Apr 20, 2014

I have a header file with a bunch of functions. I want to create a thread using the <threads> package and am using

void myclass::functionX() {
}
void myclass::function() {
std::thread tr(myclass::functionX);
}

I am getting the error "no instance of std::thread::thread matches the argument list argument types are (void());

View 1 Replies View Related

C :: Defining Array In One Function And Using It In The Next?

Nov 15, 2013

I'm trying to define a 7x5 array in main and then use it in a different function that will fill that array with random floats between 0.0 and 1.0 and then use main to print the final, filled array.

Here is what I have so far:

Code:
#include <stdio.h>
#include <stdlib.h>
main () {
float array [7][5];
printf ("%f", array);

[Code] ....

I keep getting the following error message:

testinghw10.c: In function 'fillArray':
testinghw10.c:17: error: subscripted value is neither array nor pointer

I'm not sure what the problem is? Am I calling "array" variable incorrectly or did I initialize it wrong? Or something else entirely?

View 8 Replies View Related

C++ :: Defining Classes And Using Them Inside Void Main Function

May 18, 2013

This is a program I developed in which we had to define a class named BOOK with the data members and member functions as shown in the program..We have to:

(i) Make the user enter the values in the array BOOK.
(ii) Display the details that the user entered.
(iii) Search for a book from the array upon its Bno and display its details.
(iv) Search for a book from the array upon its Bname and display its details.

PROGRAM:

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class BOOK {
private:
int Bno;
char Bname[20];

[Code] .....

But while running it the compiler gives the errors as:

Line 43 to 48: Illegal character '' (0x5c)
Line 69: Undefined symbol 'Display'
Line 88: 'BOOK::Bno' is not accessible.
Line 89:'BOOK::Bname' is not accessible.
Line 90:'BOOK::Author' is not accesible.
Line 91:'BOOK::Price' is not accesible.
Line 108:'BOOK::Bno' is not accessible.
Line 109:'BOOK::Bname' is not accessible.
Line 110:'BOOK::Author' is not accesible.
Line 111:'BOOK::Price' is not accesible.
from 43 to 48..the line feed was also used at many other places but there it was not given as an error so why here?
Line 69: I defined the Display() function outside the class since it contained control structures, so what's the error then?

About the lines the rest of the error( the "not accessible" ones) I know these data members are not accessible because they are in private visibility mode. But then how to make them accessible? (Without putting them in public because it was a part of the question to create the data members in private).

View 1 Replies View Related

C++ :: Calling A Function From A Header To Another Header?

May 16, 2014

I'm doing a compiler, and I'm using writing everything in headerfiles.

at the moment I have lexer.h, token.h and for this case I need reservedWords.h

reservedWords.h is made up of enums showing the needed words

in token.h I have a function called reservedWords reservedLookup(string str) which returns a reservedWord (enum)

now in lexer.h I have a function called Token* getNextToken() in which I need to make use of the function reservedLookup found in token.h

note that all of them are classes apart from reservedwords as in

class Lexer
{
public: .....
}
class token
{
public .....
}

how I can call that function?

I tried declaring reservedWords reservedLookup (string str) BUT obviously it's directing me as Lexer::reservedLookup and not as Token::reservedLookup

When I tried using Token::reservedLookup it gave me

E:Universitycompilerslexer.h|65|error: cannot declare member function 'Token::reservedLookup' within 'Lexer'|

N.B I use namespace std, that's why I didnot write std::string str

View 1 Replies View Related

C++ :: Defining Struct In Separated Class File ERROR

Oct 20, 2013

i've defined an strcuct in .h file and i read its variable in a method in .cpp file ,but i'v got error.

.H file:
class myclass{
public:
struct opt_struct

[Code]....

when i declare the struct without static , it doesn't recognize my struct and with static i face linker error:

Error33error LNK1120: 1 unresolved externals

View 3 Replies View Related

C++ :: How Templates Are Implemented Internally

Feb 25, 2013

How templates are implemented internally?

Theoretically templates are nothing but a generic routines. But how it has been implemented internally?What complier exactly does?

View 3 Replies View Related

C# :: Use Of Auto-implemented Properties?

Jan 28, 2014

Code using auto-implemented property:

public class MyClass {
public int age { get; set; }
}
static void Main(string[] args) {
MyClass testing = new MyClass();
testing.age = 44;
Console.WriteLine(testing.age);
}

output: 44

Code using regular variable declaration:

public class MyClass {
public int age;
}
static void Main(string[] args) {
MyClass testing = new MyClass();
testing.age = 44;
Console.WriteLine(testing.age);
}

output: 44

Why use the auto-implemented property when you can just as equally use the second code block to achieve the same thing?

View 14 Replies View Related

C++ :: Call To Member Function X Is Ambiguous - Overloaded Member From Header File

Feb 23, 2014

I get the following error in XCode whenever I try to access the member I created 'randomGen' in a separate class in a different header file. I have made sure to include the header file and have tried to access it through an object.

This is the code I enter when trying to access the method from randomiser.h in main.cpp. It is also an overloaded function with doubles and integers:

RandomG randomiser;
randomiser.randomGen(); // 'Call to member function 'randomGen' is ambiguous'

This is the code inside randomiser.h:

#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
class RandomG {

[Code] ....

This is the error inside xcode: [URL] ....

I have tried seperating the code for the functions in another class (main.cpp) and then running and it seems to works, so I'm not sure why I can't put everything in the .h file and then access it?

I would like it in a seperate file so it doesn't clutter my main. I am writing a game with SDL so that might be confusing and I would like the window to have a random title and other random properties, so it would be easier to use a function.

View 3 Replies View Related

C++ :: Deque Implemented As Vector Of Vectors?

Apr 14, 2014

I am unable to imagine implementation of deque as it promises random access,insertion and deletion at both ends in constant time.

If a deque is implemented as vector of vectors how it can do 'random access' & 'insertion/deletion at the front' in constant time?

View 3 Replies View Related

C++ :: Define Entry Point For Console Application - Printing Info Value Of Body

Aug 8, 2013

// First_VB_Prog.cpp : Defines the entry point for the console application.//

#include <iostream>
using namespace std;
//Simple Linked List composing of a "Body" , "Head" and a "Tail"
struct nodeType {

[Code] .....

View 3 Replies View Related

C :: Calculate Black Body Spectra Over User-entered Range Of Wavelength And Temperatures

Jul 29, 2013

I tried to write a code to calculate black body spectra over an user-entered range of wavelength and temperatures. The equation I'm trying to code is the second one this image (stolen from Wikipedia)The syntax to run it is bbgrid lambda_inic lambda_final temp_inic temp_final inc_T inc_lambda

where bbgrid is the name of the program, lambda_inic and lambda_final are the limits of the wavelenght range (in units of angstroms, 1A=10⁻⁰m), temp_inic and temp_final are the limits of the temperature range (in Kelvins) and inc_T and inc_lambda are the increments. What I want to do is, given the ranges of temperatures and wavelengths, to run the code over the lambdas and the temperatures.

The problem is that the behaviour of the intensities (what I'm calculating) is erratic. Sometimes it is highly positive, sometimes immensely negative and turning between those two. As an example of an output file, I'm getting things like this:

3100 1915076038
3110 -1233496775
3120 1741010116
3130 1229780625
3140 421722788
3150 -1874760945
3160 1654746252
3170 1062468321
3180 -795217626
3190 -1141129750
3200 -1570716956
3210 539385985

While I was trying to debug the code, I found the problem may reside in the exponential factor in the denominator. I wrote some lines to calculate and print on the screen only the exponential, and it was oscillating like crazy. The output file should produce curves like this:

Code:

#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<string.h>

[code]....

View 14 Replies View Related

C :: Program To Simulate Taxi Rank Implemented As Queue Via Array - Linked List

Mar 26, 2013

I have an assignment where i am required to code up in C, a program to simulate a taxi rank that is implemented as a queue via an array that can hold up to a maximum of six taxis.When a taxi arrives, it joins the rear of the queue. When a taxi departs, the first taxi in the rank is used and its departure is logged.A "rolling menu" comprising integer codes as specified below is used until 0 is entered to exit the simulation. I've done this stage but now the next stage is asking me to implement the queue as a linked list. what the difference is between an array and a linked list and what is a linked list?

View 2 Replies View Related

C++ :: Implementation File Versus Header File - Eclipse Giving Errors

Feb 10, 2013

I have written my program and it works when I keep everything in the header files, and then have my main. I am now splitting them up into implementation files, but Eclipse keeps giving me errors. It gives me error at every opening brace of the constructor and functions. It says on all of them "Redefinition of (name of constructor or method), Previously declared here." What am I doing wrong, because it works in the header file?

#include "KeyValuePair.h"
template<typename Key,typename Value>
KeyValuePair<Key,Value>::KeyValuePair()

[Code] .....

View 3 Replies View Related

C++ :: Overloaded Operator Defined In Header File - Gives Error In CPP File Of Class

Apr 12, 2014

I am working on an assignment in which i have to perform th following task

myClass itsObject1,itsObject2;
itsObject2=5000+itsObject1;

I have defined overloaded operator as follows in the header file but in the cpp file of the class it gives error.

friend vli &vli::operator + (int &a,vli &obj);

How to define it in cpp file of my class?

View 1 Replies View Related

C++ :: Splitting Template Class To Header H File And Implementation CPP File

Sep 12, 2014

What is the right syntax for implementing the .cpp of a template class?

Consider this LinkedList.h file:
Code: #include<iostream>
#include"Iterator.h"

template <class T>
class LinkedList {

[Code] ....

How should the implementation for the LinkedList constructor, for example, should look like in the LinkedList.cpp file?

I tried this:

Code: #include "LinkedList.h"
template <class T>
LinkedList<T>::LinkedList<T>() {
// constructor
}
LinkedList<T>::~LinkedList<T>() {
// destructor
}

But the compiler wouldn't accept it.

View 4 Replies View Related







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