cout

    -3热度

    1回答

    这个问题上有一些帖子,但我认为这是最简单的例子之一,希望能够澄清关于cout和初始化的一些事情。 所以此工程: class A { public: std::ostream& operator<< (std::ostream& os) { return os; } }; class B { std::ostream& operator<<

    -3热度

    1回答

    我试图在C++中构建printf函数;它的工作,但是当我打印int和float,我得到一个0我输入的任何值。 #include <iostream> #include <stdarg.h> using namespace std; void printf1(const char* varlist, ...) { int i = 0; va_list Paramters; va_s

    2热度

    2回答

    鉴于以下C++代码段,所述行为和输出为预期: #include <iostream> using namespace std; class A { public: int n; int *p; A(int n); }; A::A(int n) { this->n = n; this->p = &n; cout << *(th

    -1热度

    1回答

    所以我想用C++构建一个简单的程序,我是一个完整的C++初学者,请尽量保持简单! 这是我的代码: #include <iostream> using namespace std; int main() { char lastName[30]; int previousBalance; int payments; int charges; cout >> "Please ent

    3热度

    2回答

    比方说,我们有: char x = 'a'; int y = 1; 所以,如果你运行: std::cout << x + y; 它打印出98,而不是 'B'。正如我从here看到的 <<operator只有int参数实现。 从现在开始,我有2个问题: 字符+ INT操作后返回什么类型? 为什么没有char参数实现,但std::cout << x仍然按预期工作并打印char值?

    -1热度

    1回答

    我正在研究C++中的线性和二次探测哈希表实现。在Hash.cpp中,我有一个可用的linearProb(int key)和quadProb函数。如果我通过main.hpp单独调用它们,它会打印出正确的散列表,但是我想在编译时看到线性表和二次表的结果。 这是我linearProb(quadProb比较相似) void Hash::linearProb(int key){ int i, c

    -1热度

    1回答

    我目前正在努力学习C++的基础知识。我使用视觉工作室,并发现了一个奇怪的问题: #include "stdafx.h" #include <iostream> using namespace std; int main() { string name = "Example name"; cout << "Hello " << name << endl;

    3热度

    2回答

    实际上,我工作的一个C++字符串反转/字符[]的方法 #include <iostream> using namespace std; void inverse(string input) { int length = input.length(); char* output = new char[length]; for(int i = 0; i < l

    1热度

    2回答

    后我已经写了一小块的代码组合COUT和scanf的其中COUT打印一个语句,然后scanf的读一个值的整数变量年龄。但是,只有当我为年龄和按下输入值输入一些值时,才会打印该声明。请找到下面的代码。我想在cpp.sh #include <iostream> #include <cstdio> int main(){ int age; std::cout << "Please enter

    1热度

    3回答

    下面的程序仍然交错输出到std::cout。我试图add a std::mutex to control access到std::cout通过std::lock_guard,但它still interleaves。 #include <iostream> #include <chrono> #include <thread> #include <functional> #include <