开发者

Unexpected termination when pushing a shared_ptr into a list

I have some function:

void addNormalLine(int id, LineNumber number, Rate smsRate, Rate callRate) {
list<Account>::iterator iAccounts;
        findAccount(iAccounts, id);
        if(iAccounts == listOfAccounts.end()){
            throw "AccountDoesNotExist";
        }
if(lineExists(number)){
            throw "LineExists";
        } else{
            iAccounts->increaseNumLines();开发者_Go百科
            shared_ptr<Line> currentLine(new Line(id, number, smsRate, callRate));  //here I have some problems
            listOfLines.push_back(currentLine);  //without these two rows it works, but didn't add lines to my list
        }
    }
Account, Rate, LineNumber - some classes

but It always add only one or two numbers, if I add 3 it always terminates and and I recieve terminated, exit value: 3, I tried google it, but didn't find, what is than supposed to mean, thanks in advance


It's a bad practice to use strings as exception values. Use classes for exceptions, at least something like std::runtime_error() or better create a new class derived from it.

Make sure you catch exceptions you're throwing in this method.

What's the definition of findAccount?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜