int:redefinition(C ++)

时间:2015-07-26 02:32:36

标签: c++ add calculator redefinition

#include <iostream> 
#include <stdio.h>
#include <string>

using namespace std;

int x, y;
int main()

{

    cout << "Please give me a number:";
    int x = (cin, x);

    cout << "Please give me another number:";
    int y = (cin, y);

    cout << "The sum of " << x;
    cout << "and " << y;
    cout << "is " << x+y;
}

任何人都可以告诉我为什么(这么简单)这个没有添加? 我不确定如何返回数字之类的用户输入。刚开始学习这个。

2 个答案:

答案 0 :(得分:3)

我相信而不是:

int x = (cin, x);

你想要这个:

cin >> x;

cin c onsole in put)与cout的工作方式非常相似( c out put),您使用得当。

您可能希望更多地了解它们:

此外,您无需在x中重新定义ymain(),因为它们是全局变量。

答案 1 :(得分:1)

正确的代码是:

Cake\ORM\Query Object
(
    [(help)] => This is a Query object, to get the results execute or iterate it.
    [sql] => SELECT IntAdmin.id AS `IntAdmin__id` FROM int_admins IntAdmin INNER JOIN sales Sales ON Sales.id = (IntAdmin.sale_id) INNER JOIN accounts Accounts ON Accounts.id = (IntAdmin.account_id) WHERE (IntAdmin.status = :c0 AND IntAdmin.id in (:c1))
    [params] => Array
        (
            [:c0] => Array
                (
                    [value] => submitted
                    [type] => string
                    [placeholder] => c0
                )

            [:c1] => Array
                (
                    [value] => Array
                        (
                            [0] => 10
                            [1] => 11
                        )

                    [type] => integer
                    [placeholder] => c1
                )

        )

    [defaultTypes] => Array
        (
            [IntAdmin.id] => integer
            [id] => integer
            [IntAdmin.user_id] => integer
            [user_id] => integer
            [IntAdmin.username] => string
            [username] => string
            [IntAdmin.sale_id] => integer
            [sale_id] => integer
            [IntAdmin.account_id] => integer
            [account_id] => integer
            [IntAdmin.pl_number] => string
            [pl_number] => string
            [IntAdmin.receiving_date] => datetime
            [receiving_date] => datetime
            [IntAdmin.status] => string
            [status] => string
        )

    [decorators] => 0
    [executed] => 
    [hydrate] => 1
    [buffered] => 1
    [formatters] => 1
    [mapReducers] => 0
    [contain] => Array
        (
            [Sales] => Array
                (
                )

            [Accounts] => Array
                (
                )

        )

    [matching] => Array
        (
        )

    [extraOptions] => Array
        (
        )

    [repository] => App\Model\Table\IntAdminTable Object
        (
            [registryAlias] => IntAdmin
            [table] => int_admins
            [alias] => IntAdmin
            [entityClass] => App\Model\Entity\IntAdmin
            [associations] => Array
                (
                    [0] => users
                    [1] => accounts
                    [2] => sales
                )

            [behaviors] => Array
                (
                )

            [defaultConnection] => default
            [connectionName] => default
        )

)

阅读Basic_Syntax