1
votes

This is my third C++ application, so I am a beginner. Please have a look at the following code

Main.cpp

#include<iostream>
#include <string>
#include "GradeBook.h"

using namespace std;

int main()
{
    GradeBook myGradeBook1("Java");
    GradeBook myGradeBook2("C++");

    cout << "Course Name is: " << myGradeBook1.getCourseName() << endl;
    cout << "Course Name2 is: " << myGradeBook2.getCourseName() << endl;
}

GradeBook.h

#include <iostream>
#include <string>

using namespace std;

class GradeBook
{
private:
    string courseName;

public:

    GradeBook(string name)
    {
        setCourseName(name);
    }

    void setCourseName(string name)
    {
        courseName = name;
    }

    string getCourseName()
    {
        return courseName;
    }

    void displayMessage()
    {
        cout << "Welcome to " << getCourseName() << endl;
    }
};

Now, when I run the program (I use netbeans, compiler is cygwin), it gives the following error:

> "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS=
> .build-conf make[1]: Entering directory
> `/cygdrive/c/Users/Yohan/Documents/NetBeansProjects/LearnCPlusPlus'
> "/usr/bin/make"  -f nbproject/Makefile-Debug.mk
> dist/Debug/Cygwin-Windows/learncplusplus.exe make[2]: Entering
> directory
> `/cygdrive/c/Users/Yohan/Documents/NetBeansProjects/LearnCPlusPlus'
> mkdir -p build/Debug/Cygwin-Windows rm -f
> build/Debug/Cygwin-Windows/ClassWithPara.o.d g++    -c -g -MMD -MP -MF
> build/Debug/Cygwin-Windows/ClassWithPara.o.d -o
> build/Debug/Cygwin-Windows/ClassWithPara.o ClassWithPara.cpp
> ClassWithPara.cpp:28:4: warning: no newline at end of file mkdir -p
> dist/Debug/Cygwin-Windows g++     -o
> dist/Debug/Cygwin-Windows/learncplusplus
> build/Debug/Cygwin-Windows/IfStatement.o 
> build/Debug/Cygwin-Windows/ClassWithConstructors.o 
> build/Debug/Cygwin-Windows/HelloWorld.o 
> build/Debug/Cygwin-Windows/ClassWithSetters.o 
> build/Debug/Cygwin-Windows/ClassWithPara.o 
> build/Debug/Cygwin-Windows/FirstClass.o 
> build/Debug/Cygwin-Windows/AddIntegers.o  
> nbproject/Makefile-Debug.mk:68: recipe for target
> `dist/Debug/Cygwin-Windows/learncplusplus.exe' failed make[2]: Leaving
> directory
> `/cygdrive/c/Users/Yohan/Documents/NetBeansProjects/LearnCPlusPlus'
> nbproject/Makefile-Debug.mk:65: recipe for target `.build-conf' failed
> make[1]: Leaving directory
> `/cygdrive/c/Users/Yohan/Documents/NetBeansProjects/LearnCPlusPlus'
> nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
> /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o): In
> function `main':
> /usr/src/debug/cygwin-1.7.16-1/winsup/cygwin/lib/libcmain.c:39:
> undefined reference to `_WinMain@16' collect2: ld returned 1 exit
> status make[2]: *** [dist/Debug/Cygwin-Windows/learncplusplus.exe]
> Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl]
> Error 2
> 
> 
> BUILD FAILED (exit value 2, total time: 11s)
1
Seems like you're building a GUI app (WinMain is the entry point for those). Change it to Console app in your IDE. - jrok
Close all unrelated projects. If you don't have any unrelated projects please move your project files into a new project. - Zeta
Hi guys, Thanks for the help. jrok: In netbeans, I can't see any "GUI app" or "console app" option. @zeta: I added the code to a new project. Thanks :) Why both of you don't add the comments as "Answers" ? Then I can make one as "selected" and can give upvotes for both :) - PeakGen
@zeta: Please submit your comment as an answer. Then I can accept it and mark this topic as solved :) - PeakGen

1 Answers

1
votes

The only specific message in there says

ClassWithPara.cpp:28:4: warning: no newline at end of file mkdir -p

Have you tried adding a newline at the end of that file?

(Technically it's required, although that's not always enforced.) It's unclear from the output you give whether that really is just a warning or if it's being treated as an error.