小编And*_*er-的帖子

错误:标识符“ cout”未定义。包含<iostream>并使用命名空间std;

我正在尝试cout一些变量,但是编译器会这样说cout is undefined。我已经包含了iostream,并且正在使用命名空间std。删除问题using namespace stdusing std::cout改为将问题更改为“名称空间“ std”没有成员“ cout””。我发现一些答案说要添加# include "stdafx.h"到代码中,但是Error: cannot open source file "stdafx.h"会发生。

代码是:

#include "Complex.h"
#include <cmath>
#include <iostream>

using namespace std;

Complex::Complex(int PolarOrRectang, float RealOrArg, float ImagOrAng) {
    if (PolarOrRectang == 0) {
        real = RealOrArg;
        imag = ImagOrAng;
    else {
        real = RealOrArg * cos(ImagOrAng);
        imag = RealOrArg * sin(ImagOrAng);
    }
};

void Complex::getValue(int PolarOrRectang) {
    if (PolarOrRectang == 0) {
        cout << …
Run Code Online (Sandbox Code Playgroud)

c++ cout undefined

3
推荐指数
1
解决办法
1万
查看次数

使用python3 Mountain Lion在tkinter中制作工具栏/菜单

在用tkinter修补后,我似乎无法让我的窗户看起来像我想要的样子.但总的来说,我不确定文件编辑视图布局是指什么.这是工具栏还是菜单?

到目前为止,我的gui看起来比我想要的少得多.我应该一起抛弃tkinter吗?

有没有人有一个代码剪切,给出了一般的osx布局?那将是一个很大的帮助.也许我只是没有从概念上理解gui编程方面.

谢谢

我想将菜单添加到以下代码中

from tkinter import *
from tkinter import ttk


def undef(*args):
    pass
def undef2(*args):
    pass

root = Tk()


root.title("KDM Checker Beta ")

mainframe = ttk.Frame(root, padding="5 5 5 5")
mainframe.grid(column=12, row=12, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)






countryvar = StringVar()
country = ttk.Combobox(mainframe, textvariable=countryvar)
country['values'] = ('dolby', 'sony', 'doremi')
country.grid(column=1, row = 1)


DATE = StringVar()
VENUE = StringVar()
UUID = StringVar()
SERVER_SERIAL = StringVar()

DATE_entry = ttk.Entry(mainframe, width=8, textvariable=DATE)
DATE_entry.grid(column=3, row=4, sticky=(W, E)) …
Run Code Online (Sandbox Code Playgroud)

python tkinter

2
推荐指数
1
解决办法
3839
查看次数

如何在Metal中将数组从顶点着色器传递到片段着色器

在GLSL中,我将简单地使用out vec3 array[10];,将一个数组从顶点着色器传递到片段着色器。但是,在Metal中,我想这样做:

struct FragmentIn {
    float4 position [[position]];
    float3 array[10];
};
Run Code Online (Sandbox Code Playgroud)

这将产生以下错误:

Type 'FragmentIn' is not valid for attribute 'stage_in' because field 'array' has invalid type 'float3 [10]'

我该如何解决这个问题?我需要使用片段着色器将使用的每个顶点数据进行某些计算。

metal

2
推荐指数
1
解决办法
456
查看次数

将目录移至垃圾箱

我需要将目录(包括其内容)移动到垃圾箱.我NSWorkspaceRecycleOperation在文档中找到了,并编写了这段代码:

NSString *path = [NSString stringWithString:@"/Users/test/Desktop/test"];

NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];

[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation 
                                             source:path 
                                        destination:@"" 
                                              files:dirContents 
                                                tag:nil];
Run Code Online (Sandbox Code Playgroud)

它将所有内容移动到垃圾箱,而不是目录本身.那么,我该怎么做呢?

cocoa objective-c

1
推荐指数
1
解决办法
2278
查看次数

JQuery - 在鼠标悬停时淡出颜色

当鼠标悬停在div元素上时,我有以下JQuery代码将div的背景颜色淡化为不同的颜色.它工作得很好,但它需要jqueryui.js才能工作.我的页面已经将jquery.js用于其他目的,所以我必须加载两个框架.

这可以只用jquery而不是jqueryui来完成吗?

<!-- fade page onload -->
$(document).ready(function(){
    $('#page_effect').fadeIn(1000);
});
<!-- fade login form to color on hover -->
$(document).ready(function() {
    $("#frmLogin").hover(function() {
        $(this).stop().animate({ backgroundColor: "#fff"}, 800);
    }, function() {
        $(this).stop().animate({ backgroundColor: "#e6e6e6" }, 800);
    });
});
Run Code Online (Sandbox Code Playgroud)

谢谢!

jquery

1
推荐指数
1
解决办法
3万
查看次数

NSWindow调整大小时调整表列大小

我正在使用NSTableView的Cocoa应用程序上工作。

现在,我希望通过用户从角落拖动应用程序或单击缩放按钮来在用户调整窗口大小或最大化窗口时自动调整表视图中列的宽度。

任何帮助将不胜感激。

macos cocoa nstableview nstablecolumn

1
推荐指数
1
解决办法
595
查看次数

C++ 套接字 - send() 和 connect()

我是套接字编程的新手。我正在用 C++ 制作一个客户端套接字,我的朋友正在制作一个服务器端套接字(也是用 C++ 编写),我们的目标是一起制作一个聊天应用程序。作为套接字编程的新手,我在互联网上搜索 C++ 套接字及相关内容,并且收集了足够的信息来创建套接字并向另一个套接字发送内容。问题出在sendconnect函数上。我真的不明白我应该在其中包含哪些参数,以及如何初始化这些参数。我希望有更多经验的人可以解释它们是如何工作的,以及使用什么值作为参数。这是 MSDN 的代码示例。我希望有人帮忙!不管怎样,谢谢!

\n\n
int send(\n  _In_       SOCKET s,\n  _In_ const char   *buf,\n  _In_       int    len,\n  _In_       int    flags\n);\n\nint connect(\n  _In_ SOCKET                s,\n  _In_ const struct sockaddr *name,\n  _In_ int                   namelen\n);\n
Run Code Online (Sandbox Code Playgroud)\n\n

我已经知道如何创建套接字,所以我知道第一个参数是什么;这是插座。

\n\n

编辑2:

\n\n

这些是我使用的模块;我不确定它们是否是我应该使用的;我只是从网上看到的 C++ 套接字示例中复制了它们。

\n\n
#include<iostream>    //cout\n#include<stdio.h> //printf\n#include<string.h>    //strlen\n#include<string>  //string\n#include<sys/socket.h>    //socket\n#include<arpa/inet.h> //inet_addr\n#include<netdb.h> //hostent\n
Run Code Online (Sandbox Code Playgroud)\n\n

另一件事 \xe2\x80\x94 我正在使用 UDP 协议。不确定这是否会影响任何事情,呵呵!

\n

c++ sockets connect send

1
推荐指数
1
解决办法
4万
查看次数

如何获取用`@ property`装饰的所有方法的列表?

如何获取已经用@property装饰器装饰的类的所有方法的列表?

有了下面的例子,答案应该得到一个只有xy包含的列表,但不是z,因为它没有用@property以下装饰:

class C(object):
    def __init__(self):
        self._x = None
        self._y = None

    @property
    def x(self):
        """I'm the 'x' property."""
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

    @x.deleter
    def x(self):
        del self._x

    @property
    def y(self):
        return self._y

    def z(self):
        pass
Run Code Online (Sandbox Code Playgroud)

python

1
推荐指数
1
解决办法
46
查看次数

Python 3类错误

我正在尝试通过使用类来制作一个小程序.到目前为止,我已经创建了两个类,其中第一个将运行下一个类.当我运行它时,我收到一条错误消息.我不明白什么是错的,但看起来它有一些关于我Menu1在读取之前定义名称的事情.我将在这些类之后创建一个新函数,它将首先运行MainWindow,然后再运行Menu1.我很感激帮助.

码:

class MainWindow:
    app = Tk()
    app.title("MyApp")
    window = Frame(app, width=1050, height=550)
    app.minsize(width=1050, height=550)
    window.pack()
    menu = Menu1()
    menu.makeMenu()
    app.mainloop()


class Menu1:
    def makeMenu(self):
        app.config(menu=menu)
        menu.add_cascade(label="Settings", menu=subMenu)
        subMenu.add_command(label="Settings", command=settings1)

def settings1():
    print("Open new window")


if __name__ == "__main__":
    MainWindow()
Run Code Online (Sandbox Code Playgroud)

错误信息:

Traceback (most recent call last):
  File "", line 7, in <module>
    class MainWindow:
  File "", line 13, in MainWindow
    menu = Menu1()
NameError: name 'Menu1' is not defined

Process finished with exit code …
Run Code Online (Sandbox Code Playgroud)

python tkinter python-3.x

0
推荐指数
1
解决办法
96
查看次数

与swift中`return`的功能相混淆

return在Swift中感到困惑.我知道它用于返回函数中的值,如果像这样使用:

func double(value: int) -> Int { 
    return value * 2
}
Run Code Online (Sandbox Code Playgroud)

但我经常只是看到return被使用,就像在这样guard的可选绑定中的语句:

guard let value = value else (
    print ("nothing")
    return
}
Run Code Online (Sandbox Code Playgroud)

那么return在这样的guard声明中有什么目的呢?实际上,我经常guard在展开可选值时在语句中看到这一点.当我想使用字典中的可选字符串时,我总是在编写代码时发现这个问题.

let info = ["name": "sarah", "hometown": "sydney"]

class UserInfo {

    func getTheName() -> String {
        guard let name = info["name"] else { return }

        return name
    }
}
// Compile time error: "Non-void function should return a value"
Run Code Online (Sandbox Code Playgroud)

即使我写过,我也会收到此错误return name.Xcode仍抱怨我没有返回值.是因为return …

return ios swift

0
推荐指数
1
解决办法
2149
查看次数

C++:无法使用“=”运算符更改 std::pair 的值

我正在尝试更新 an 的值std::pair,但这会导致编译器错误。如何解决这个问题?

#include <unordered_map>
#include <utility>
#include <string>
#include <iostream>

int main(int argc, char *argv[])
{
    std::unordered_map<int, std::pair<std::string, std::string>> test1;
    test1.insert(std::make_pair(1, std::make_pair("good1", "bad1")));
    test1.insert(std::make_pair(2, std::make_pair("good2", "bad2")));
    test1.insert(std::make_pair(3, std::make_pair("good3", "bad3")));
    test1.insert(std::make_pair(4, std::make_pair("good4", "bad4")));

    std::unordered_map<int, std::pair<std::string, std::string>>::const_iterator test2
        = test1.find(1);

    if (test2 == test1.end())
    {
        std::cout << "Could not find test2 in test1\n";
        return 0;
    }

    std::cout << "First item is: " << test2->second.first << "...second item is: " << test2->second.second << "\n";

    /* This line is throwing an …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
176
查看次数