I have this assignment where I need to program something I guess like a package, so I would be able to include the header file and run the functions from my c++ file in my main c++ file, so what I have is something like this, and it doesn't work :3
So the error I keep getting is:
1 IntelliSense: identifier "bubbleSort" is undefined c:\users\padv62090eo\documents\visual studio 2010\projects\sortingalgorithms\sortingalgorithms\sortingalgorithms.cpp 43 2 SortingAlgorithms
I hope you have an idea of what's going on, because I'm pretty lost :/
Refers to a function which is either member of a class or inside a namespace.
You declare int bubbleSort(int arr); in myHeaderfile.h, which is in the file/global scope, so you do not need the Sort:: in front of the function.
I got it to run in C::B;
Your include hpp int* bubbleSort(int*);
Your function cpp
1 2 3 4 5 6 7 8 9 10 11 12
int* bubbleSort(int* arr)
for (int i=1 ; i<10 ; i++)
for (int t=1 ; t<10-i ; t++)
if (arr[t] < arr [t-1])
int temp = arr[t];
arr[t] = arr[t-1];
arr[t-1] = temp;
I should say, that it didn't work for me returning an undefined array size (int), since you have only 1 array size in your program, why not return a pointer? Note that an array is basically a pointer that has allocated x elements, just not as explicitly as we do with pointers.
Thanks for the reply, I tried to take another approach to it all, and I seem to have it solved somehow :D
I did more or less as you described :3 but now it gives me an error like this:
Unable to start program
missing .dll file
Your include guard is placed wrongly, it should encapsulate the entirety of the header file. "StdAfx.h" in one file and "stdafx.h" in another. Back when I used visual studio, the pre-compiled header was named "stdafx.h", not "StdAfx.h", try renaming that.
it appears when I try to run the application, it pops up with the window stating that there are errors in the program, then you press continue, and it fails to build because of the missing dll file :3
apparently it should be a myLibrary.dll located in my Debug folder, however it isn't there,
could it be because I made the myLibrary.h a namespace myLibrary?