PDA

View Full Version : ISO-C++ verbietet Deklaration von »bikinmenupos« ohne Typ [-fpermissive]



opentek
24th August 2021, 04:31
Dear my friends of Qt-Community.

I'm stucked on this error-message as I am building 2 windows (1 as parent-window and 1 as child-window) and MenuBar (with QMenuBar and QMenu). The error-message as compiling-process is here:
"
ceo@sally:/mnt/slax/fileserver-slax/arsip/SoftDev/ERPLinux$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt/mkspecs/linux-g++ -I. -I/usr/lib64/qt/include/QtCore -I/usr/lib64/qt/include/QtGui -I/usr/lib64/qt/include -I. -I. -o ERPLinux.o ERPLinux.cpp
In file included from ERPLinux.cpp:1:0:
ERPLinux.h:15:14: Fehler: ISO-C++ verbietet Deklaration von »bikinmenupos« ohne Typ [-fpermissive]
bikinmenupos(){
^
ERPLinux.h: In Funktion »int bikinmenupos()«:
ERPLinux.h:18:3: Fehler: »berkaspos« wurde in diesem Gültigkeitsbereich nicht definiert
berkaspos = menupos->addMenu("&POS");
^
ERPLinux.h:16:13: Warnung: Variable »menuutama« wird nicht verwendet [-Wunused-variable]
QMenuBar *menuutama = new QMenuBar();
^
ERPLinux.h:19:1: Warnung: keine return-Anweisung in nicht void zurückgebender Funktion [-Wreturn-type]
}
^
ERPLinux.cpp: In Funktion »int main(int, char**)«:
ERPLinux.cpp:8:11: Fehler: expected unqualified-id before »->« token
ERPLinux->bikinmenupos();
^
Makefile:214: die Regel für Ziel „ERPLinux.o“ scheiterte
make: *** [ERPLinux.o] Fehler 1
ceo@sally:/mnt/slax/fileserver-slax/arsip/SoftDev/ERPLinux$
".

"Fehler: ISO-C++ verbietet Deklaration von »bikinmenupos« ohne Typ [-fpermissive]" means -> "Error: ISO-C++ declared from »bikinmenupos« without Type [-fpermissive]".
"Fehler: »berkaspos« wurde in diesem Gültigkeitsbereich nicht definiert" means -> "Error: »berkaspos« defined not in corrent region/position.

These are my simple-sourcecode (4-files):
-------------------------
1. file of ERPLinux.h
#include <QApplication>
#include <QWidget>
#include <QMenuBar>
#include <QMenu>

class QAction;
class ERPLinux : public QWidget{
Q_OBJECT
public:

private:

};

bikinmenupos(){
QMenuBar *menuutama = new QMenuBar();
QMenu *menupos = new QMenu();
berkaspos = menupos->addMenu("&POS");
}

2. file of ERPLinux.cpp
#include "ERPLinux.h"
#include "POS.h"

int main(int argc, char *argv[]){
QApplication *aplikasi = new QApplication(argc, argv);
QWidget *jendelautama = new QWidget();
jendelautama->setWindowTitle("ERP for Windows, Linux and Android by ELEKTRO.asia");
ERPLinux->bikinmenupos();

jendelautama->show();
POS *layarpos = new POS();
layarpos->show();
aplikasi->exec();
}

3. file of POS.h
#include <QWidget>

class QAction;
class POS : public QWidget{

public:

};

4. file of POS.cpp
#include "POS.h"

int main(int argc, *char argv[]){

}
-----------------------------------

Would anyone please help me to show where my mistakes I've done?

Thank you very much in advance.

Ginsengelf
24th August 2021, 06:57
Hi, your bikinmenupos() function does not have a return value. If you don't want to return anything it should be "void bikinmenupos()".

Ginsengelf

opentek
24th August 2021, 17:17
Liebe Ginsengelf.

Thank you very much for your advise. I have put "void bikinmenupos(){...}".

And now I am still trouble-shooting these error-message:
"
ceo@sally:/mnt/slax/fileserver-slax/arsip/SoftDev/ERPLinux$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt/mkspecs/linux-g++ -I. -I/usr/lib64/qt/include/QtCore -I/usr/lib64/qt/include/QtGui -I/usr/lib64/qt/include -I. -I. -o ERPLinux.o ERPLinux.cpp
In file included from ERPLinux.cpp:1:0:
ERPLinux.h: In Funktion »void bikinmenupos()«:
ERPLinux.h:18:3: Fehler: »berkaspos« wurde in diesem Gültigkeitsbereich nicht definiert
berkaspos = menupos->addMenu("&POS");
^
ERPLinux.h:16:13: Warnung: Variable »menuutama« wird nicht verwendet [-Wunused-variable]
QMenuBar *menuutama = new QMenuBar();
^
ERPLinux.cpp: In Funktion »int main(int, char**)«:
ERPLinux.cpp:8:11: Fehler: expected unqualified-id before »->« token
ERPLinux->bikinmenupos();
"

Added after 16 minutes:

Liebe Ginsengelf....

Now I still have 2 error-message left to be solved. I change my file of ERPLinux.h like this:
"
#include <QApplication>
#include <QWidget>
#include <QMenuBar>
#include <QMenu>

class QAction;
class ERPLinux : public QWidget{
Q_OBJECT
public:

private:

};

void ERPLinux::bikinmenupos(){
QMenuBar *menuutama = new QMenuBar();
QMenu *menupos = new QMenu();
berkaspos = menupos->addMenu("&POS");
}
"

I still have these 2problems
"
ERPLinux.h:15:29: Fehler: keine Elementfunktion »void ERPLinux::bikinmenupos()« in Klasse »ERPLinux« deklariert
" means
"
ERPLinux.h:15:29: Error: no functionelement »void ERPLinux::bikinmenupos()« declared in class of »ERPLinux«
"

d_stranz
24th August 2021, 17:43
ERPLinux.h:15:29: Fehler: keine Elementfunktion »void ERPLinux::bikinmenupos()« in Klasse »ERPLinux« deklariert
" means
"
ERPLinux.h:15:29: Error: no functionelement »void ERPLinux::bikinmenupos()« declared in class of »ERPLinux«
"

Are you actually reading your compiler's error messages?

Your "ERPLinux" class is completely empty. You haven't declared any methods or variables in it. If you want "bikinmenupos()" to be a member function of this class, then you have to declare it inside of the class definition.

I think you need to go back to your C++ books and read again about classes and class definitions.

opentek
24th August 2021, 19:46
Dear dstanz

Not completely empty, isn't it? I defined
"
void ERPLinux::bikinmenupos(){
QMenuBar *menuutama = new QMenuBar();
QMenu *menupos = new QMenu();
berkaspos = menupos->addMenu("&POS");
}
"
and I call
"
ERPLinux->bikinmenupos();
" from ERPLinux.cpp .

I shouldn't go-back to my C++ book yet but I better go-back to wxWidget as I usually use GUI-lib for writing my application in C++.

d_stranz
24th August 2021, 23:43
Not completely empty, isn't it?

Yes, it is. This is a completely empty declaration of the class ERPLinux. All you have done here is to say it is a class publicly derived from QWidget. The only actual content is the Q_OBJECT macro.



class ERPLinux : public QWidget{
Q_OBJECT
public:

private:

};


I defined



void ERPLinux::bikinmenupos(){
QMenuBar *menuutama = new QMenuBar();
QMenu *menupos = new QMenu();
berkaspos = menupos->addMenu("&POS");
}

This is not the way you declare a class member function. It must be declared within the body of the class declaration:



class ERPLinux : public QWidget{
Q_OBJECT
public:
void bikinmenupos();

private:

};

and then you can define (implement) it, usually in the .cpp file that corresponds to your .h file, or as inline in your .h file.

And this line:


berkaspos = menupos->addMenu("&POS");

won't compile because you have not declared a variable named "berkaspos".

Likewise, your class "POS" is also completely empty.

And this:


ERPLinux->bikinmenupos();

is not the way you call a member function of the class ERPLinux. Which is why you need to go back to your C++ book.

opentek
25th August 2021, 05:07
Dear d_stanz...

Thank you very much for your advises..... I am retrying to progress my sourcecode now.