Solved

VC to C++ Builder code conversion

Posted on 2003-10-29
2
437 Views
Last Modified: 2010-08-05
I am trying to convert some code from VC to C++ Builder 5 pro.

For the line:
operator string() const;
I get these errors:
Error E2076 .\strtok.h 32: Overloadable operator expected
Error E2040 .\strtok.h 32: Declaration terminated incorrectly

Farther down in the implementation:
inline StrTok::operator string() const
{
  if (curToken)
      return string(curToken,curTokenLength);
  return string("");
}
I get these errors:
Error E2076 .\strtok.h 59: Overloadable operator expected
Error E2040 .\strtok.h 59: Declaration terminated incorrectly

This is a small and relatively uncomplicated class, but I am stuck on what the Borland C++ Builder compiler is looking for.

What should I replace these with?
I tried AnsiString(), but it gave the exact same errors.
0
Comment
Question by:c567591
2 Comments
 
LVL 15

Accepted Solution

by:
efn earned 300 total points
ID: 9643549
It doesn't recognize "string" as a type.  I reproduced those error messages in BCB 4 and got rid of them by inserting these lines above the class declaration:

#include <string>

using std::string;

--efn
0
 
LVL 1

Author Comment

by:c567591
ID: 9643644
Well, you just got some easy points.  ;)
Thanks for the quick answer that worked!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now