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


ADVERTISEMENT

C++ :: Calling Header File From A Centralized Folder

May 27, 2014

Scenario as below:

I have two module, A and B

Module A:
- A.cpp & A.h

Module B:
- B.cpp & B.h

and then for these two *.h file i put in another centralized folder call HeaderFile.

when I #include "B.h" from A.cpp, the compiler show me Error code C1083.

View 3 Replies View Related

Visual C++ :: Should Precompiled Header Files Also Be Included In Source Header Files?

Sep 16, 2013

When including a header file in stdafx.h, should that file still be included in the source file where it is actually used?

If it is included in both places, is the one in the source file ignored?

View 5 Replies View Related

C++ :: Function Call From Header

Nov 27, 2014

I've got These 3 files:

// OTI.h
extern void Unpack(void* Packet);

// PackUnpack.cpp
#include "OptiTrackInterface.h"
void Unpack(void* Packet) {
...
}

// OTI.cpp
#include "OptiTrackInterface.h"
Unpack((char*) &indata);

When i try to compile OTI.cpp, I got the error that Unpack is undeclared.

View 2 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

Visual C++ :: What Header For Sleep Function

Jan 26, 2014

I have been googling for a long time to find the header used with sleep().

View 5 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++ :: Header And Prototype Correct But No Matching Function For Call To?

Dec 10, 2014

For whatever reason, I get an error meassage about lines 53-57 saying there is no matching function to call to. Yet the header and the prototype are correct (I think anyways).

#include <iostream>
#include <string>
#include <fstream>
#define N 10
using namespace std;
class cust{

[Code] ....

View 5 Replies View Related

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 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++ :: Returning Datatype Other Than The Declared Function Header Datatype

Jun 6, 2013

I have designed a class called matrixType that has some overloaded operators (+, -, *, and <<); the arithmetic operator functions of which are overloaded as member functions of the class. As an alert mechanism, I want a message displayed when two matrices of dissimilar sizes are added/subtracted OR when two incompatible matrices are being multiplied. Displaying this error message is not the problem. However, I want a scheme where on detecting two matrices’ incompatibility, the operator function returns the error message (a string datatype) instead of what would be an erroneous result (the expected matrixType object).

In other words, what I may be essentially asking is: Is it possible for a function, say,

matrixType matrixType::operator+(const matrixType& otherMatrix) const
{
.
.
.
}

to return a dataType (like a string) other than the expected matrixType?

View 1 Replies View Related

C++ :: Using (this) In Template Header?

Sep 28, 2013

i have 1 class:

from here: [URL]

template <typename Container, typename ValueType, void (Container::*setptr)(ValueType t),ValueType (Container::*getptr)(), int nPropType=3>
class property {

[code]....

(but i did the version 2;))

my question is: can i put these:

void setContainer(Container* cObject) {
m_cObject = cObject;
}

in header template?

i did these:

template <typename Container,Container* cObject, typename ValueType, void (Container::*setptr)(ValueType t),ValueType (Container::*getptr)(), int nPropType=3>
class property {

[Code] .....

how use it:

property <person2,this,string,&person2::setname,&person2::getname> Name;

(person2 is the class name)

errors messages:

"C:UsersJoaquimDocumentsCodeBlocks esteventsmain.cpp|31|error: invalid use of 'this' at top level|"

"C:UsersJoaquimDocumentsCodeBlocks esteventsmain.cpp|31|error: template argument 2 is invalid|"

how can i use the 'this' in template header?

View 1 Replies View Related

C :: Defines And Header File

Mar 23, 2013

1. Write a program the calculates the volume of a sphere.

Use a define to set Pi to 3.14 and a macro for the formula for the sphere.
V = 4/3PiR3.
In main ask for the radius (R).
Pass it to a function where you calculate the volume and return it to main and print the volume in main.
Use float values. (Save this program as you'll need it later.)

Code:

#include<stdio.h>
void fun (float);
main()

[Code].....

View 8 Replies View Related

C :: Header Files Not Found On Mac

Nov 2, 2013

I have a piece of code in C with header files included. I run it on Mac OS X Maverick with XCode 4.6.2 installed. GCC is also installed. Note that Command Line Tools in XCode are already installed.

When I compile it, the error I receive says something like this:

add.c:1:19: error: stdio.h: No such file or directory add.c:2:20: error: stdlib.h: No such file or directory add.c:3:20: error: unistd.h: No such file or directory

However when I run it on Ubuntu, it compiles without a problem.What to do?

View 2 Replies View Related

C++ :: Using Namespaces In Header Files

Dec 9, 2013

So I've been making a header file and put variables in their own namespace to avoid conflicts. My question is, do functions in the header file normally go in a namespace too, or should they just be named in a way which makes them unlikely to be accidentally copied?

View 15 Replies View Related

C++ :: MP3 Frame Header Importing

Jun 24, 2013

Code:

/* some useful headers */
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

//my headers
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>

[XCode] .....

The bit that's giving me issues is the "calculatedetails" function, where an mp3 file is opened in binary and then an array of chars is filled with the binary data.

The problem I'm having is that I want to be able to read the constituent bits of the characters in, so that I can find the mp3 frame headers (12 1's in succession)

I'm aware that the section I've added in to perform this is incorrect.

View 7 Replies View Related

C++ :: Header File Namespace

May 19, 2013

Can we put using namespace std; in a header file? Someone told me not to do it, but I don't know why...

View 2 Replies View Related

C++ :: Read A File With Header?

Jun 4, 2013

I need read a file with header and I wanna print the file in output. How can I do that? I tried but not work..

#include<iostream>
#include<fstream>
using namespace std;
int main()
{

[Code]....

View 1 Replies View Related

C++ :: How To Modify A Header Of Any File

Jul 24, 2013

All i want to do is modify a header of a file(.exe file). I just want to do if for fun and see what I can do with it.

View 3 Replies View Related

C++ :: Header File Inclusions

Apr 11, 2013

I have a class Myclass (for the sake of the example). I have a header file 'space.h', which is following:

#include "Myclass.h"
struct Files {Myclass* new_object, int number};

But turns out in the Myclass.h, I need the struct Files, like so:void function(vector<Files> arrangement);

So I would have to include "space.h" in the Myclass.h, but this way there's going to be a double definition of struct Files, since Myclass.h includes space.h and space.h includes Myclass.h.

View 4 Replies View Related

C++ :: Precompiled Header Files

Apr 2, 2013

My teacher talks about header files just having definitions and not declerations. I am writing a program that has a .h file and a related .cpp file along with a main.cpp it would be nice to have the .cpp file associated with the .h file compiled into an object file that would than just be referenced when the .h file is included. Am I making any sense?

View 2 Replies View Related

C++ :: How To Use Two Header Files In Program

Sep 17, 2013

I want to use two header files in my program. Here is exactly what I want to do.

-In the first header I have a binary tree and a structure.
-In the second file I have another functions that need to use the structure in the first header.
-I also want to use a function from the second header in the first.
-And finally I want to do actions with both headers in a "main.cpp" file that contains only int main() function.

How to include the headers in each other and in the main.cpp to be able to do the actions above?

I try to include the first header in the second one and the second one in the first header. Then I include both headers in the main.cpp file. But the compiler shows me many errors.

View 5 Replies View Related

C++ :: How To Create Header File

Oct 22, 2013

Any good/solid example on how to create a header file?

View 2 Replies View Related







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