You are here:

C++/user defined header files

Advertisement


Question
sir, i declare a header file like this

namespace compare
   {
         double max(int i, float j);
   }
but after compiling this will give error as

-----declaration syntax error
what is the problem

Answer
# include <iostream>
using namespace std;
#include "header.h"

int main ()
{
  using namespace compare;
  cout << x << endl;
  cout << add (x,x) << endl;
  return 0;
}
===================================
namespace compare
{
  int x = 5;
  int add (int, int);
}

int compare::add (int x, int y)
{
  return x+y;
}

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Dharmender Rai

Expertise

I can answer general and system level C/C++ questions.

Experience

I have 5 years of experience in C++.

©2016 About.com. All rights reserved.