473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Appears to be Function Definition

Hi, I am new here. I am also a first-year computer science student looking for some help with a very small C++ program.
This is a 3-file program, header file with declarations and 2 source files, one for definition and the other is the actual application file. I am attempting to write a non-member function.
In my header file, I have declared bool isLarger(int x, int y); outside of the class. In my application file, before the end of the program, I have written the following code:
Expand|Select|Wrap|Line Numbers
  1. bool isLarger(firstDate.convert(), secondDate.convert())
  2. {
  3.  
  4.     if (firstDate.convert() > secondDate.convert())
  5.     {
  6.         cout << "The first date entered is the most recent. " << endl << endl;
  7.         return true;
  8.     }
  9.     else
  10.     {
  11.         cout << "The second date entered is the most recent. " << endl << endl;
  12.         return false;
  13.     }
  14. }
  15.  
When compiling this, the only error message I receive is: "error C2448: 'isLarger' : function-style initializer appears to be a function definition".

I think that that is what I intended - a function definition. Is there something illegal about this code that I am just not seeing?

Thank you in advance for any help.

Michelle
Oct 30 '07 #1
3 5018
oler1s
671 Expert 512MB
bool isLarger(firstDate.convert(), secondDate.convert())

Mind telling us what that is supposed to be?
Oct 30 '07 #2
Sure. I'm calling the results of date conversions for the two separate objects of my CDate class - firstDate and secondDate. The point of this particular portion of this assignment is to compare the results of the convert method and cout which object is larger.
Oct 30 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
bool isLarger(firstDate.convert(), secondDate.convert())
{

if (firstDate.convert() > secondDate.convert())
{
cout << "The first date entered is the most recent. " << endl << endl;
return true;
}
else
{
cout << "The second date entered is the most recent. " << endl << endl;
return false;
}
}
You are confusing writing a function with calling a function. The compiler wants to know what the types of the arguments are and not where you are getting them from.

The above is a function definiton, not a call.
Expand|Select|Wrap|Line Numbers
  1. bool isLarger(int, int)  <<<< 
  2. {
  3. //etc
  4. }
  5.  
Oct 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
5
by: Daniel Nichols | last post by:
I've noticed that in a C module (.c, .h file combination) that if you create a function's definition before it is used in other functions than a declaration is not necessary. I believe if the...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
42
by: baumann | last post by:
hi all, typedef int (*pfunc)(int , int); pfunc a_func; i know it's ok, but how can define a_func without typedef statement? thanks .
9
by: Netocrat | last post by:
Any comments on the correctness of the statements 1, 2a, 2b, 3 and 4 in the code below? If they are correct, then the definition of an object as well as that of an lvalue is broken in C99 by the...
26
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null);...
4
by: Paulo Matos | last post by:
Hi all, I'm trying to work out a parser for function declarations but it turns out that it is harder than I initially thought. I'm looking at 3rd Ed of Stroustrup, page 808. I'm trying to parse...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
14
by: jg | last post by:
Does C++ standard require an inline function be generated all the time ? For example, #include <iostream> using namespace std; inline int foo() {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.