И теперь сверху жалуются, что мой код "слишком сишный", то есть написан на Си без плюсов, хоть я и использую классы. Проблема в том, что никто из коллег на работе не может нормально объяснить, как, собственно должен выглядеть "плюсовый" код.
int j = 0;
char s[] = "hello\n";
char ch;
while (s[j])
{
ch = s[j];
putchar(toupper(ch));
j++;
}
std::string s("hello");
std::transform(s.begin(), s.end(), s.begin(),
[](unsigned char c) -> unsigned char { return std::toupper(c); });
const Polygon operator+( const Polygon& lhs,const Polygon& rhs )
{
Polygon ret = lhs;
const int last = rhs.GetNumPoints();
for( int i = 0; i < last; ++i ) // Конкатенация
{
ret.AddPoint( rhs.GetPoint(i) );
}
return ret;
}
for(int i{0}; i < input.length(); ++i)
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <memory>
template<typename Derived>
struct Clonable{
public:
virtual ~Clonable() = default;
std::unique_ptr<Derived> clone(){ return std::unique_ptr<Derived>( vclone() ); }
protected:
virtual Derived* vclone() const = 0;
};
class MyClass : public Clonable<MyClass>{
public:
void print() const { std::cout << "I'm a MyClass!" << std::endl; }
std::unique_ptr<MyClass> clone() { return std::unique_ptr<MyClass>{ vclone() }; }
protected:
virtual MyClass* vclone() const = 0;
};
class Implementation : public MyClass{
public:
virtual Implementation* vclone() const override
{
return new Implementation(*this);
}
};
int main()
{
Implementation impl;
MyClass* a = &impl;
std::unique_ptr<MyClass> b = a->clone();
a->print();
return 0;
}
Modifies the default numeric base for integer I/O.
я уже на третьем телефоне>
Вот это вот, что такое? И зачем оно вообще?