• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

AP Programming Question

jmcoreymv

Diamond Member
Im using VC++ 6 and Im trying to use the AP String class but when I link it, I get a bunch of unresolved external errors. The compile however is fine. And its a really simple program which im copying out of the lesson so I know its not my code. What causes unresolved symbols and stuff like that?
 
Post your code here.
Apstring has some weird ass errors sometimes, that usually have nothing to do with the class itself.
 
Just use cstring

Dunno if it's available in VC++, but it works the same in Borland (only thing my crappy school can afford).

Josh
 
Heres the code:

#include<iostream.h>
#include"apstring.h"
void testConstructors();

int main()
{
testConstructors();
return(0);
}

void testConstructors()
{
apstring word1;
apstring word2("Hello World\0");
apstring word3("Hello World\n");
cout<<"Testing constructors"<<endl<<endl;
cout<<word1;
cout<<word2;
cout<<word3;
}

Heres the errors:

Linking...
strings231.obj : error LNK2001: unresolved external symbol "public: __thiscall apstring::~apstring(void)" (??1apstring@@QAE@XZ)
strings231.obj : error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class apstring const &)" (??6@YAAAVostream@@AAV0@ABVapstring@@@Z)
strings231.obj : error LNK2001: unresolved external symbol "public: __thiscall apstring::apstring(char const *)" (??0apstring@@QAE@PBD@Z)
strings231.obj : error LNK2001: unresolved external symbol "public: __thiscall apstring::apstring(void)" (??0apstring@@QAE@XZ)
Debug/strings231.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

strings231.exe - 5 error(s), 0 warning(s)
 


<< Try including "apstring.cpp" instead of .h >>



No.. apstring is a class. It has to be called like a class. And the class is in the H file.
Try <apstring.h> just for sh|ts and giggles.
 


<<

<< Try including "apstring.cpp" instead of .h >>



No.. apstring is a class. It has to be called like a class. And the class is in the H file.
Try <apstring.h> just for sh|ts and giggles.
>>


that might help, but he might now have the header/class files in the right directory.
Have you used the AP classes on this computer before
 
I have used two other ap classes so far, apvector and apmatrix. Both seemed to work fine. The compiler is the one thats part of VC++ 6 as part of Enterprise Edition of VS. I also have the Architect Version of VS NET but I cant figure out how to make that thing compile. The option always stays greyed out. If I use the include<> it still gives the same errors (I have a copy of all the files in the include directory).
 
did you include apsting.cpp in your project? apstring is the only ap class that requires the .cpp file in the project
 


<<

<< Try including "apstring.cpp" instead of .h >>



No.. apstring is a class. It has to be called like a class. And the class is in the H file.
Try <apstring.h> just for sh|ts and giggles.
>>


I know full well what a class is. I've had this problem before. Including the .cpp instead of the .h works.
 
A really quick skim of google doesn't show any implementations of:

apstring word("text");

but tons of:

apstring word = "text";

Are you sure you're calling it right?
 
I have used apstring for two years and never called a .cpp file. Not once.
Perhaps you are not calling it right.
You need to use the replacement operator:

apstring text = "text";

 
It looks like including the cpp file instead of the header file worked. How odd is that, but thanks for the help guys.
 


<< It looks like including the cpp file instead of the header file worked. How odd is that, but thanks for the help guys. >>



I don't know what the hell kind of compiler will accept that kind of call, but it isn't anything I have ever seen, not even on AP's own exam.
 


<<

<< It looks like including the cpp file instead of the header file worked. How odd is that, but thanks for the help guys. >>



I don't know what the hell kind of compiler will accept that kind of call, but it isn't anything I have ever seen, not even on AP's own exam.
>>


no sh!t.....
leave it to M$ to screw up the impementation of a great language
 


<< It wouldn't work with apstring >>


That's odd, cuz it's worked for me on several occasions, but I guess you guys know better.
rolleye.gif


Hell, a little project I've been working on at home didn't compile correctly (same/similar errors to what jmcoreymv is having) until I included "apstring.cpp."

Edit:

<< I don't know what the hell kind of compiler will accept that kind of call, but it isn't anything I have ever seen, not even on AP's own exam. >>


I've been under the impession that the #include command simply inserts whatever text is "included" be it from a text file or string literal. It doesn't matter if the text is in a .cpp or .h.

In any case, you are very welcome jmcoreymv. 🙂
 
Back
Top