• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++

Oskar1121

Excellent OT User
Joined
Jul 15, 2009
Messages
705
Reaction score
713
Location
Poland
Ok, I have this function:
PHP:
std::string Item::getWeightDescription(const Item* item/* = NULL*/, double weight, bool stackable, uint32_t count/* = 1*/)
{
    if(item && weight > 0)
        {
        std::stringstream s;
        if(stackable && count > 1)
                s << "They weigh " << std::fixed << std::setprecision(2) << weight << " oz.";
        else
                s << "It weighs " << std::fixed << std::setprecision(2) << weight << " oz.";

        return s.str();
        }
    return "";
}
In item.cpp and this in item.h:
PHP:
static std::string getWeightDescription(const Item* item = NULL, double weight, bool stackable, uint32_t count = 1);
std::string getWeightDescription() const {return getWeightDescription(this, getWeight(), items[id].stackable, count);}
I compile my engine, it displays an error:
PHP:
1520 C:\Users\Oskar\Desktop\0.3.6pl1.r83\item.cpp default argument missing for parameter 2 of `static std::string Item::getWeightDescription(const Item*, double, bool, uint32_t)'
 
You obviously need to put all default param at last of the function arguments

[cpp]
static std::string getWeightDescription(double weight, bool stackable, const Item* item = NULL, uint32_t count = 1); [/cpp]
 
Now is:
PHP:
  [Linker error] undefined reference to `Item::getWeightDescription(double, bool, unsigned int, Item const*)'



PHP:
static std::string getWeightDescription(double weight, bool stackable, const Item* item = NULL, uint32_t count = 1);
std::string getWeightDescription() const {return getWeightDescription(getWeight(), items[id].stackable, this, count);}

PHP:
std::string Item::getWeightDescription(double weight, bool stackable, const Item* item/* = NULL*/, uint32_t count/* = 1*/)
 
Back
Top