Question
Hello Please I am having this error in my c++ project, I need help please. Below is the erro which comes out each time i
Hello Please I am having this error in my c++ project, I need help please. Below is the erro which comes out each time i try to run the main.cpp.
Error LNK1120 2 unresolved externals main
C:\Users\bleac\Documents\C##\Lab5\main\Debug\main.exe 1
Error LNK2019 unresolved external symbol "double __cdecl nlc::largest(double * const,int)" (?largest@nlc@@YANQANH@Z) referenced in function _main main C:\Users\bleac\Documents\C##\Lab5\main\main.obj 1
Error LNK2019 unresolved external symbol "double __cdecl nlc::smallest(double * const,int)" (?smallest@nlc@@YANQANH@Z) referenced in function _main main C:\Users\bleac\Documents\C##\Lab5\main\main.obj 1
These are my codes:
THE MAIN.CPP CODE
#include "pch.h"
#include
#include "Largest.h"
#include "Smallest.h"
//#include "Average.h"
using namespace std;
// addition of the new namespace
using namespace nlc;
int main()
{
double numbers[] = { 4.5, 3.4, 5.6, 9.1, 6.7, 7.8 };
int count = sizeof(numbers) / sizeof(double);
cout << largest(numbers, count);
cout << endl;
cout << smallest(numbers, count);
cout << endl;
//cout << Average(numbers, count);
}
HERE IS HE LARGEST.CPP COD
#include "Largest.h"
using namespace std;
namespace nlc;
{
double largest(double numbers[], int size)
{
double max = numbers[0];
for (int i = 0; i < size; i++)
{
// check if current number is greater than the max
if (numbers[i] > max) max = numbers[i];
}
return max;
}
}
HERE IS THE LARGEST.H CODE
#pragma once
#ifndef LARGEST_H
#define LARGEST_H
using namespace std;
namespace nlc
{
double largest(double[], int);
}
#endif
HERE IS THE SMALLEST.CPP CODE
#include
#include "Smallest.h"
using namespace std;
namespace nlc;
{
double smallest(double numbers[], int size)
{
double min = numbers[0];
for (int i = 0; i < size; i++)
{
// check if current number is smaller than the min
if (numbers[i] < min) min = numbers[i];
}
return min;
}
}
HERE IS THE SMALLEST.H CODE
#pragma once
#include
using namespace std;
#ifndef SMALLEST_H
#define SMALLEST_H
using namespace std;
namespace nlc
{
double smallest(double[], int);
}
#endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started