Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Large project how to seprate definition and declaration? Pin
Jochen Arndt12-Jun-16 21:47
professionalJochen Arndt12-Jun-16 21:47 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer12-Jun-16 22:37
leon de boer12-Jun-16 22:37 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 1:25
Hassan Syed113-Jun-16 1:25 
GeneralRe: Large project how to seprate definition and declaration? Pin
Richard MacCutchan13-Jun-16 1:46
mveRichard MacCutchan13-Jun-16 1:46 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer13-Jun-16 4:03
leon de boer13-Jun-16 4:03 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 4:54
Hassan Syed113-Jun-16 4:54 
SuggestionRe: Large project how to seprate definition and declaration? Pin
David Crow13-Jun-16 5:23
David Crow13-Jun-16 5:23 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer13-Jun-16 16:19
leon de boer13-Jun-16 16:19 
There Errors are explained above your header file declaration does not match your .cpp file. Even in a single file your code for Input_area and Input_trap are both bad and wrong. You will have several warnings which you are just ignoring I take it. Those warnings are real and pointing to a problem you need to fix, which becomes fatal when you turn it to a unit.

You declare this in calculation.h
void input_Area(void); //Input function of Area.

You have this in your calculation.cpp
float input_Area(void){

LOOK AT THEM .. THEY ARE NOT THE SAME .. the return declare (1st word) differs ... THAT IS YOUR FIRST PROBLEM WITH THE .H FILE

Again we repeat the declaration in the .H file must be EXACTLY the same as the interface actually in the .CPP file.

THERE IS NO EXCEPTION TO THIS RULE .... EVER

So the .H file could be changed to
float input_Area(void); //Input function of Area.

OR ... the .CPP file could be changed to
void input_Area(void){


I can't work out which definition is correct because you don't actually return anything from input_area. Either could be correct because your code has a big error I can't work out which is right. You have the same problem on float input_Trap. You declared you are returning a float but don't return anything, do you understand what I am saying when I say that????? Even in one big file you will be getting a 2 warnings, something like "function does not return value".

I am struggling why you can't see the problem because you did it correctly in rectangleArea and trapezoidArea, so you know how to return a value when you declare it. So on your code you got right lets mark where you return a float.
float rectangleArea (float width, float length)  // * PT1 ... HERE YOU DECLARE YOU ARE RETURNING A FLOAT .. the first word is FLOAT not VOID 
{
    float Area_Rectange = 0;
    Area_Rectange = width * length;
    return (Area_Rectange);  // *** HERE YOU RETURN A FLOAT ... which is exactly what you said at PT1 ... HENCE THIS CODE IS CORRECT
}

Now look at Input_area and Input_trap the word return and some value doesn't appear in the code BUT you declared you are returning a float. The compiler and I are both confused with what you are doing. If you declare a float return, then please return one. If you don't want to return a float then change the first word on the declare to void (which matches what you have in the .H file).

On the other issue yes we can move the input stuff to another .CPP and .H file and you generally try and keep units around a theme. However lets just leave it in one first and get that working correctly as you still seem to not grasp the basics and more files just confuses things more.
In vino veritas


modified 13-Jun-16 23:17pm.

GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 19:47
Hassan Syed113-Jun-16 19:47 
AnswerRe: Large project how to seprate definition and declaration? Pin
David Crow14-Jun-16 2:47
David Crow14-Jun-16 2:47 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer14-Jun-16 6:06
leon de boer14-Jun-16 6:06 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer14-Jun-16 10:01
leon de boer14-Jun-16 10:01 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed114-Jun-16 20:34
Hassan Syed114-Jun-16 20:34 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 3:53
leon de boer15-Jun-16 3:53 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 4:32
Hassan Syed115-Jun-16 4:32 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 6:21
leon de boer15-Jun-16 6:21 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 7:01
Hassan Syed115-Jun-16 7:01 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 8:04
leon de boer15-Jun-16 8:04 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 8:48
Hassan Syed115-Jun-16 8:48 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 20:00
leon de boer15-Jun-16 20:00 
QuestionGlut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 7:03
Ratul Thakur11-Jun-16 7:03 
AnswerRe: Glut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 20:02
Ratul Thakur11-Jun-16 20:02 
GeneralRe: Glut errors with Mingw on windows Pin
leon de boer11-Jun-16 22:59
leon de boer11-Jun-16 22:59 
GeneralRe: Glut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 23:59
Ratul Thakur11-Jun-16 23:59 
QuestionWhy no boundry condition set for C++ Pin
Hassan Syed111-Jun-16 4:52
Hassan Syed111-Jun-16 4:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.