PDA

View Full Version : is not a type<><> error



k.qasempour
22nd August 2012, 09:25
hi all. im trying to create a C++ library but i faced with this error " error: 'number1' is not a type"...
here is my code, what should i do ??
many thanks



# arthemticopration.pro


#-------------------------------------------------
#
# Project created by QtCreator 2012-08-22T12:05:19
#
#-------------------------------------------------

QT -= gui

TARGET = ArthemticOpration
TEMPLATE = lib

DEFINES += ARTHEMTICOPRATION_LIBRARY

SOURCES += arthemticopration.cpp

HEADERS += arthemticopration.h\
ArthemticOpration_global.h

symbian {
MMP_RULES += EXPORTUNFROZEN
TARGET.UID3 = 0xE0E61B47
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
addFiles.sources = ArthemticOpration.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
}

unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}

__________________________________________________


// arthemticopration.cpp


#include "arthemticopration.h"
ArthemticOpration::ArthemticOpration()
{

}

int ArthemticOpration::add(number1, number2)
{
return number1+number2;
}

__________________________________________________ _


// arthemticopration.h



#ifndef ARTHEMTICOPRATION_H
#define ARTHEMTICOPRATION_H

#include "ArthemticOpration_global.h"

//ARTHEMTICOPRATIONSHARED_EXPORT void foo();


class ARTHEMTICOPRATIONSHARED_EXPORT ArthemticOpration {
public:
ArthemticOpration();

private:
ARTHEMTICOPRATIONSHARED_EXPORT int number1;
ARTHEMTICOPRATIONSHARED_EXPORT int number2;
ARTHEMTICOPRATIONSHARED_EXPORT int add(ARTHEMTICOPRATIONSHARED_EXPORT number1,ARTHEMTICOPRATIONSHARED_EXPORT number2);
};

#endif // ARTHEMTICOPRATION_H


__________________________________________________ ________________________

// ArthemticOpration_global.h



#ifndef ARTHEMTICOPRATION_GLOBAL_H
#define ARTHEMTICOPRATION_GLOBAL_H

#include <QtCore/qglobal.h>

#if defined(ARTHEMTICOPRATION_LIBRARY)
# define ARTHEMTICOPRATIONSHARED_EXPORT Q_DECL_EXPORT
#else
# define ARTHEMTICOPRATIONSHARED_EXPORT Q_DECL_IMPORT
#endif

#endif // ARTHEMTICOPRATION_GLOBAL_H

yeye_olive
22nd August 2012, 10:16
The argument list in the declaration and definition of the add() method does not follow the syntax of C++. This is basic C++, by the way, and has nothing to do with Qt.

Coises
23rd August 2012, 01:53
hi all. im trying to create a C++ library but i faced with this error " error: 'number1' is not a type"...
here is my code, what should i do ??

Set up and debug your code as an ordinary subroutine first, before you try to make a library of it.

Seriously, I’m not being facetious... you’re way ahead of yourself. Write a simple main routine to call your functions, and write your header(s) and implementation file(s) as part of the same project. Get that to compile and run correctly before you try to figure out how to package it into a library.

You have some “beginner” errors there, and there’s just way too much extraneous stuff (ARTHEMTICOPRATIONSHARED_EXPORT everywhere, whether it belongs or not) going on for a beginner.