English 中文(简体)
C++ 病媒/级
原标题:C++ Vectors / Classes /Threading

I m Using Win7 / VS2008 (9) SDK 6/7.1

i faced a problem in a code that i m using
the mini version of the code as follows

class CONNECTION
{
    int/std::string/bool vars; // just to make it simple
    CONNECTION ( int defaultvar );
    CONNECTION ( const CONNECTION& copycon )
    ~CONNECTION ( );
    DWORD static WINAPI staticstart( void *param )  //HACK to use createthread on classes
    { return ((CONNECTION *)param)->main); } // yea it works fine
    DWORD main();
};

this class has no default constructor with a copy and a destructor all vars are copied fine and destructor leaves no memleaks, constructor is simple as assigning the paramters to a var .. all vars and code are omitted to make it simple and because they aren t the prob.

class main
{
    std::vector<CONNECTION> con;
    int addcon( int defaultvarofcon )
    {
        CONNECTION temp( defaultvar );
        con.push_back( temp );
        return con.size() - 1;
    }
}

so far so good when i run a console test program that only have an include and this code

main mymainclass;
mymainclass.addcon( 0 );

program runs fine closes without errors
but when i add extra code like

main mymainclass;
mymainclass.addcon( 0 );
mymainclass.addcon( 1 );
mymainclass.addcon( 2 );

program crashes with access violation after checking my code twice i debugged it step by step on all threads i found out the main thread can read correct values of all vector class/elements in both main thread and worker thread ONLY if i m using one element at the vector

然而,如果使用像第二部法典这样不止一个版本的米,则无法获得有关自己深层所有要素(坏点)的数据,但主要线上的数据仍然正确,显示正确的价值。

谁能帮助我了解这一法典有什么错误?

最佳回答

http://www.ohchr.org。 因此,你们必须使用某种交换机,确保每次只能使用一种透镜。

否则,如果任何翻新都转播病媒,病媒可能必须分配新的储存、复印件、然后释放旧的储存......并明显释放旧的储存,而其他一些翻新正在使用该储存是一种非常坏的事情。

您需要分配<代码>CONNECTION Object yourself。 让我们看<条码>,即:病媒转水器/密码管理,这意味着当病媒转水时,他们会被转往记忆中,而其他read子的点子则被 left弃。 病媒的恢复使所有点人对其任何内容都无效。

问题回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签