Search Results

Search found 1771 results on 71 pages for 'knowing me knowing you'.

Page 4/71 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • extern(al) problem

    - by Knowing me knowing you
    Why can't I compile this code? //main #include "stdafx.h" #include "X.h" #include "Y.h" //#include "def.h" extern X operator*(X, Y);//HERE ARE DECLARED EXTERNAL *(X,Y) AND f(X) extern int f(X); /*GLOBALS*/ X x = 1; Y y = x; int i = 2; int _tmain(int argc, _TCHAR* argv[]) { i + 10; y + 10; y + 10 * y; //x + (y + i); x * x + i; f(7); //f(y); //y + y; //106 + y; return 0; } //X struct X { int i; X(int value):i(value) { } X operator+(int value) { return X(i + value); } operator int() { return i; } }; //Y struct Y { int i; Y(X x):i(x.i) { } Y operator+(X x) { return Y(i + x.i); } }; //def.h int f(X x); X operator*(X x, Y y); //def.cpp #include "stdafx.h" #include "def.h" #include "X.h" #include "Y.h" int f(X x) { return x; } X operator*(X x, Y y) { return x * y; } I'm getting err msg: Error 2 error LNK2019: unresolved external symbol "int __cdecl f(struct X)" Error 3 error LNK2019: unresolved external symbol "struct X __cdecl operator*(struct X,struct Y)" Another interesting thing is that if I place the implementation in def.h file it does compiles without errs. But then what about def.cpp? Why I'm not getting err msg that function f(X) is already defined? Here shouldn't apply ODR rule. Second concern I'm having is that if in def.cpp I change the return type of f from int to double intelliSense underlines this as an error but program still compiles? Why?

    Read the article

  • Using undefined type.

    - by Knowing me knowing you
    //file list.h #include "stdafx.h" namespace st { struct My_List; typedef My_List list; list* create(const char* name); } //file list.cpp #include "stdafx.h" #include "list.h" namespace st { struct My_List { const char* name_; My_List* left_; My_List* right_; My_List(const char* name):name_(name), left_(nullptr), right_(nullptr) {} My_List(const My_List&); ~My_List() { } void insert(My_List*); void set_name(char* name) { name_ = name; } const char* get_name()const { return name_; } }; typedef My_List list; /*helper class for optor+ */ struct MyChar { const char* my_data_; MyChar(const char* c_string):my_data_(c_string){} operator const char*() { return my_data_; } operator char*() { return const_cast<char*>(my_data_); } }; char* operator+(MyChar left_, MyChar right_) { if (!left_.my_data_ || !right_.my_data_) { return 0; } size_t size = 1;//size is set to one for final '\0' char in an array char* p = "";//if both c_strings are empty this is returned bool has_left_ = false; bool has_right_ = false; if (strlen(left_)) { size += strlen(left_); has_left_ = true; } if (strlen(right_)) { size += strlen(right_); has_right_ = true; } bool both = has_left_ && has_right_ ? true : false; if (both) { p = new char[size](); const void* p_v = p;//just to keep address of beginning of p const char* tmp = left_; /*copying first c_string*/ while (*p++ = *tmp++); tmp = right_; /*one too far after last loop*/ --p; while (*p++ = *tmp++); *p = '\0'; /*go back to the beginning of an array*/ p = static_cast<char*>(const_cast<void*>(p_v)); return p; } else if (has_left_) { return left_; } else if (has_right_) { return right_; } return p;//returns "" if both c_strings were empty } My_List::My_List(const My_List& pat):left_(nullptr),right_(nullptr) { name_ = pat.name_ + MyChar("_cpy"); My_List* pattern = const_cast<My_List*>(&pat); My_List* target = this; while (pattern->right_) { target->right_ = static_cast<My_List*>(malloc(sizeof(My_List))); *target->right_ = *pattern->right_; target->right_->set_name(pattern->right_->get_name() + MyChar("_cpy")); target->right_->left_ = static_cast<My_List*>(malloc(sizeof(My_List))); *target->right_->left_ = *pattern->right_->left_; target->right_->left_->set_name(pattern->right_->left_->get_name() + MyChar("_cpy")); pattern = pattern->right_; target = target->right_; } } void My_List::insert(My_List* obj) { /*to catch first branch*/ My_List* tmp = this; if (tmp->right_) { /*go to the end of right side*/ while (tmp->right_) { tmp = tmp->right_; } tmp->right_ = obj; obj->left_ = tmp; } else { tmp->right_ = obj; obj->left_= this; } } My_List* create(const char* name) { return new My_List(name); } } //file main.cpp #include "stdafx.h" #include "list.h" using namespace st; int _tmain(int argc, _TCHAR* argv[]) { list* my = create("a"); list* b = create("b"); my->insert(b);//HERE I'M GETTING ERROR return 0; } err msg: 'Error 1 error C2027: use of undefined type 'st::My_List' 13' Why? Especially that if I comment this line it will get compiled and create() is using this type.

    Read the article

  • Knowing the selections made on a 'multichooser' box in a mechanical turk hit (using Command Line Too

    - by gveda
    Hi All, I am new to Amazon Mechanical Turk, and wanted to create a hit with a qualification task. I am using the command line tools interface. One of the questions in my qualification task involves users selecting a number of options. I use a 'multichooser' selection type. Now I want to grade the responses based on the selections, where each selection has a different score. So for example, s1 has a score of 5, s2 of 10, s3 of 6, and so on. If the user selects s1 and s3, he/she gets a score of 11. Unfortunately, doing something like the following does not work: <AnswerOption> <SelectionIdentifier>s1</SelectionIdentifier> <AnswerScore>5</AnswerScore> </AnswerOption> <AnswerOption> <SelectionIdentifier>s2</SelectionIdentifier> <AnswerScore>10</AnswerScore> </AnswerOption> <AnswerOption> <SelectionIdentifier>s3</SelectionIdentifier> <AnswerScore>6</AnswerScore> </AnswerOption> If I do this, when I select multiple things, I get a score of 0. If I select only one option, say s1, then I get the appropriate score. Can you please help me on how to go about this? I could ask the same question 5 times with the same options, but then users might choose the same answer multiple times - something I wish to avoid. Thanks! Gaurav

    Read the article

  • Can you find a pattern to sync files knowing only dates and filenames?

    - by Robert MacLean
    Imagine if you will a operating system that had the following methods for files Create File: Creates (writes) a new file to disk. Calling this if a file exists causes a fault. Update File: Updates an existing file. Call this if a file doesn't exist causes a fault. Read File: Reads data from a file. Enumerate files: Gets all files in a folder. Files themselves in this operating system only have the following meta data: Created Time: The original date and time the file was created, by the Create File method. Modified Time: The date and time the file was last modified by the Update File method. If the file has never been modified, this will equal the Create Time. You have been given the task of writing an application which will sync the files between two directories (lets call them bill and ted) on a machine. However it is not that simple, the client has required that The application never faults (see methods above). That while the application is running the users can add and update files and those will be sync'd next time the application runs. Files can be added to either the ted or bill directories. File names cannot be altered. The application will perform one sync per time it is run. The application must be almost entirely in memory, in other words you cannot create a log of filenames and write that to disk and then check that the next time. The exception to point 6 is that you can store date and times between runs. Each date/time is associated with a key labeled A through J (so you have 10 to use) so you can compare keys between runs. There is no way to catch exceptions in the application. Answer will be accepted based on the following conditions: First answer to meet all requirements will be accepted. If there is no way to meet all requirements, the answer which ensures the smallest amount of missed changes per sync will be accepted. A bounty will be created (100 points) as soon as possible for the prize. The winner will be selected one day before the bounty ends. Please ask questions in the comments and I will gladly update and refine the question on those.

    Read the article

  • Intersection of line with cube and knowing the point of intersection.

    - by Raj
    Hello everyone, description 1.lines are originating from origin(0,0,0). 2.lines are at some random angle to the Normal of Top face of teh cube. 3.if the lines are intersecting cube , calculate the intersection point. 4.mainly i wan to know how much distance ,line traveled inside the cube. I dont know exactly which approach should i take , i will be pleased and thankful if someone could guied me to the right direction, to use OpenGL, DirectX or some other library, for C# . some example or sample will be appriciated.

    Read the article

  • Any tool(s) for knowing the layout (segments) of running process in Windows?

    - by claws
    I've always been curious about How exactly the process looks in memory? What are the different segments(parts) in it? How exactly will be the program (on the disk) & process (in the memory) are related? My previous question: http://stackoverflow.com/questions/1966920/more-info-on-memory-layout-of-an-executable-program-process In my quest, I finally found a answer. I found this excellent article that cleared most of my queries: http://www.linuxforums.org/articles/understanding-elf-using-readelf-and-objdump_125.html In the above article, author shows how to get different segments of the process (LINUX) & he compares it with its corresponding ELF file. I'm quoting this section here: Courious to see the real layout of process segment? We can use /proc//maps file to reveal it. is the PID of the process we want to observe. Before we move on, we have a small problem here. Our test program runs so fast that it ends before we can even dump the related /proc entry. I use gdb to solve this. You can use another trick such as inserting sleep() before it calls return(). In a console (or a terminal emulator such as xterm) do: $ gdb test (gdb) b main Breakpoint 1 at 0x8048376 (gdb) r Breakpoint 1, 0x08048376 in main () Hold right here, open another console and find out the PID of program "test". If you want the quick way, type: $ cat /proc/`pgrep test`/maps You will see an output like below (you might get different output): [1] 0039d000-003b2000 r-xp 00000000 16:41 1080084 /lib/ld-2.3.3.so [2] 003b2000-003b3000 r--p 00014000 16:41 1080084 /lib/ld-2.3.3.so [3] 003b3000-003b4000 rw-p 00015000 16:41 1080084 /lib/ld-2.3.3.so [4] 003b6000-004cb000 r-xp 00000000 16:41 1080085 /lib/tls/libc-2.3.3.so [5] 004cb000-004cd000 r--p 00115000 16:41 1080085 /lib/tls/libc-2.3.3.so [6] 004cd000-004cf000 rw-p 00117000 16:41 1080085 /lib/tls/libc-2.3.3.so [7] 004cf000-004d1000 rw-p 004cf000 00:00 0 [8] 08048000-08049000 r-xp 00000000 16:06 66970 /tmp/test [9] 08049000-0804a000 rw-p 00000000 16:06 66970 /tmp/test [10] b7fec000-b7fed000 rw-p b7fec000 00:00 0 [11] bffeb000-c0000000 rw-p bffeb000 00:00 0 [12] ffffe000-fffff000 ---p 00000000 00:00 0 Note: I add number on each line as reference. Back to gdb, type: (gdb) q So, in total, we see 12 segment (also known as Virtual Memory Area--VMA). But I want to know about Windows Process & PE file format. Any tool(s) for getting the layout (segments) of running process in Windows? Any other good resources for learning more on this subject? EDIT: Are there any good articles which shows the mapping between PE file sections & VA segments?

    Read the article

  • Which cast am I using?

    - by Knowing me knowing you
    I'm trying to cast away const from an object but it doesn't work. But if I use old C-way of casting code compiles. So which casting I'm suppose to use to achieve this same effect? I wouldn't like to cast the old way. //file IntSet.h #include "stdafx.h" #pragma once /*Class representing set of integers*/ template<class T> class IntSet { private: T** myData_; std::size_t mySize_; std::size_t myIndex_; public: #pragma region ctor/dtor explicit IntSet(); virtual ~IntSet(); #pragma endregion #pragma region publicInterface IntSet makeUnion(const IntSet&)const; IntSet makeIntersection(const IntSet&)const; IntSet makeSymmetricDifference(const IntSet&)const; void insert(const T&); #pragma endregion }; //file IntSet_impl.h #include "StdAfx.h" #include "IntSet.h" #pragma region ctor/dtor template<class T> IntSet<T>::IntSet():myData_(nullptr), mySize_(0), myIndex_(0) { } IntSet<T>::~IntSet() { } #pragma endregion #pragma region publicInterface template<class T> void IntSet<T>::insert(const T& obj) { /*Check if we are initialized*/ if (mySize_ == 0) { mySize_ = 1; myData_ = new T*[mySize_]; } /*Check if we have place to insert obj in.*/ if (myIndex_ < mySize_) {//IS IT SAFE TO INCREMENT myIndex while assigning? myData_[myIndex_++] = &T(obj);//IF I DO IT THE OLD WAY IT WORKS return; } /*We didn't have enough place...*/ T** tmp = new T*[mySize_];//for copying old to temporary basket std::copy(&myData_[0],&myData_[mySize_],&tmp[0]); } #pragma endregion Thanks.

    Read the article

  • Constructor is being invoked twice

    - by Knowing me knowing you
    In code: LINT a = "12"; LINT b = 3; a = "3";//WHY THIS LINE INVOKES CTOR? std::string t = "1"; //LINT a = t;//Err NO SUITABLE CONV FROM STRING TO LINT. Shouldn't ctor do it? #pragma once #include "LINT_rep.h" class LINT { private: typedef LINT_rep value_type; const value_type* my_data_; template<class T> void init_(const T&); public: LINT(const char* = 0); LINT(const std::string&); LINT(const LINT&); LINT(const long_long&); LINT& operator=(const LINT&); virtual ~LINT(void); LINT operator+()const; //DONE LINT operator+(const LINT&)const;//DONE LINT operator-()const; //DONE LINT operator-(const LINT&)const;//DONE LINT operator*(const LINT&)const;//DONE LINT operator/(const LINT&)const;///WAITS FOR APPROVAL LINT& operator+=(const LINT&);//DONE LINT& operator-=(const LINT&);//DONE LINT& operator*=(const LINT&);//DONE LINT operator/=(const LINT&);///WAITS FOR APPROVAL }; in line number 3 instead of assignment optor ctor is invoked. Why? I'm willing to uppload entire solution on some server otherwise it's hard to put everything in here. I can also upload video file. Another thing is that when I implement this assignment optor I'm getting an error that this optor is already in obj file? What's going on?

    Read the article

  • Syntax proposition

    - by Knowing me knowing you
    I wonder if syntax as follows would be helpful in your opinion as a code readability improvent and self-commenting of code: std::map<std::string name, std::vector<int> scores> myMap; In this example it clearly says and no other comment is needed, what for we are using myMap variable. Looking forward to your opinions.

    Read the article

  • Why can't I add pointers

    - by Knowing me knowing you
    Having very similiar code like so: LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator+(const Iterator& right)const { return (this + &right);//IN THIS PLACE I'M GETTING AN ERROR } LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator-(const Iterator& right)const {//substracts one iterator from another return (this - &right);//HERE EVERYTHING IS FINE } err msg: Error 1 error C2110: '+' : cannot add two pointers Why I'm getting an err in one place and not in both?

    Read the article

  • Activation rectangle

    - by Knowing me knowing you
    Making UML sequence diagram in VS 2010RC I've observed that there is no activation rectangle in first object. Is this correct? Not according to my tutor and I have to quote him: "Finally, you have no activation rectangle for the userInterface instance, so the initial message could never have been sent." But I'm thinking that if guys from VS did that it must/should be correct. Another thing he is picking me at is and I'm quoting him: "In class diagram the generalisation arrow heads should be open triangles." In my opinion there isn't strictly said that they must be open triangles especially when software lets you choose their form. Looking forward to hear your opinions. Thanks for answers.

    Read the article

  • Internal class and access to external members.

    - by Knowing me knowing you
    I always thought that internal class has access to all data in its external class but having code: template<class T> class Vector { template<class T> friend std::ostream& operator<<(std::ostream& out, const Vector<T>& obj); private: T** myData_; std::size_t myIndex_; std::size_t mySize_; public: Vector():myData_(nullptr), myIndex_(0), mySize_(0) { } Vector(const Vector<T>& pattern); void insert(const T&); Vector<T> makeUnion(const Vector<T>&)const; Vector<T> makeIntersection(const Vector<T>&)const; class Iterator : public std::iterator<std::bidirectional_iterator_tag,T> { private: T** itData_; public: Iterator()//<<<<<<<<<<<<<------------COMMENT { /*HERE I'M TRYING TO USE ANY MEMBER FROM Vector<T> AND I'M GETTING ERR SAYING: ILLEGAL CALL OF NON-STATIC MEMBER FUNCTION*/} Iterator(T** ty) { itData_ = ty; } Iterator operator++() { return ++itData_; } T operator*() { return *itData_[0]; } bool operator==(const Iterator& obj) { return *itData_ == *obj.itData_; } bool operator!=(const Iterator& obj) { return *itData_ != *obj.itData_; } bool operator<(const Iterator& obj) { return *itData_ < *obj.itData_; } }; typedef Iterator iterator; iterator begin()const { assert(mySize_ > 0); return myData_; } iterator end()const { return myData_ + myIndex_; } }; See line marked as COMMENT. So can I or I can't use members from external class while in internal class? Don't bother about naming, it's not a Vector it's a Set. Thank you.

    Read the article

  • Why typedef char CHAR

    - by Knowing me knowing you
    Guys, having quick look in Winnt.h I have discovered that there is a lots of typedefs and one of them is for example CHAR for a char. Why? What was the purpose of these typdefs? Why not use what's already there (char, int etc.)? Thank you.

    Read the article

  • Pointer arithmetic.

    - by Knowing me knowing you
    Having code: int** a = new int*[2]; a[0] = new int(1); a[1] = new int(2); cout << "a[0] " << a[0] << '\n'; cout << "a[1] " << a[1] << '\n'; cout << "a[2] " << a[2] << '\n'; cout << "a[0] + 1 " << a[0] + 1 << '\n';//WHY THIS ISN'T == a[1] ? cout << "*(a + 1): " << *(a + 1) << '\n'; //WHY THIS IS == a[1] ? cout << "a[0] - a[1] " << static_cast<int>(a[0] - a[1])<< '\n';//WHY THIS IS == 16 not 4? cout << sizeof(int**); Questions are included right next to relevant lines in code.

    Read the article

  • Which graphical enviroment?

    - by Knowing me knowing you
    Which graphical environment (MFC, ATL, QT etc.) should I concentrate on, in order to be more employable? I don't want to spend months learning something only to discover that "no one" really use this or this really sucks, and "all" pros are using only such and such.

    Read the article

  • Using ant, rename a directory without knowing the full path?

    - by mixonic
    Howdy friends, Given a zipfile with an unknown directory, how can I rename or move that directory to a normalized path? <!-- Going to fetch some stuff --> <target name="get.remote"> <!-- Get the zipfile --> <get src="http://myhost.com/package.zip" dest="package.zip"/> <!-- Unzip the file --> <unzip src="package.zip" dest="./"/> <!-- Now there is a package-3d28djh3 directory. The part after package- is a hash and cannot be known ahead of time --> <!-- Remove the zipfile --> <delete file="package.zip"/> <!-- Now we need to rename "package-3d28djh3" to "package". My best attempt is below, but it just moves package-3d28djh3 into package instead of renaming the directory. --> <!-- Make a new home for the contents. --> <mkdir dir="package" /> <!-- Move the contents --> <move todir="package/"> <fileset dir="."> <include name="package-*/*"/> </fileset> </move> </target> I'm not much of an ant user, any insight would be helpful. Thanks much, -Matt

    Read the article

  • About GridLayout.

    - by Knowing me knowing you
    Hi, if I have code like so: class X extends JFrame { X() { setLayout(new GridLayout(3,3)); JButton b = new JButton("A-ha"); /*I would like to add this button in the center of this grid (2,2)*/ //How can I do it? } }; Thanks.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >