Search Results - CodeGuru Forums
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: Philip Nicoletti

Page 1 of 80 1 2 3 4

Search: Search took 0.19 seconds.

  1. Replies
    4
    Views
    125

    Re: The issues with my piece of code

    OneDArray<OneDArray<OneDArray<int>>> arr;




    This is a simple, but inefficient way to create multi-dimensional
    arrays. As you noticed, the constructor (and hence new) is called
    many times...
  2. Re: A question regarding erasing an item from a vector

    And in your code you have:



    next = it+1;
    v.erase(it);


    The erase invalidates iterators and references at or after the point of the erase. So the "next" iterator has been invalidated.
  3. Re: A question regarding erasing an item from a vector

    Your loop should look like this:



    for(vector<int>::iterator it=v.begin();it!=v.end();/* nothing here*/)
    {
    if(*it == 14)
    {
    it = v.erase(it);
    }
  4. Re: A compiler error with the implementation of smart pointer

    I don't see that. operator= decrements the reference count and if equals 0, deletes the memory. Am I missing something ?
  5. Re: A compiler error with the implementation of smart pointer

    For shared_ptr and unique_ptr, it is up to the programmer to not dereference the owned pointer if it is the nullptr. I do not think the functions are allowed to throw, but the get() function can be...
  6. Replies
    2
    Views
    261

    Re: c++ weird error

    1) You should describe the error .. compile time ? run time ?

    2) you are accessing invalid indices in your array ...


    int list[100];

    for( int j=1; j<101; j++)
    {
    int i = rand()%61 + 40;
  7. Re: A question regarding double-checked locking

    Scott Myers and Andrei Alexandrescu wrote on this :

    http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf

    If you do not like clicking on links, do a search on:

    scott myers double...
  8. Re: A compiler error with the implementation of smart pointer

    Why would "a" become empty ? You have implemented a shared pointer.
    Both "a" and "b" share the pointer.
  9. Replies
    4
    Views
    252

    Re: Displays arrays

    Also note: arrays are stored in contiguous memory. Using that information, you can write a
    single function to compute the total of the array, no matter how many dimensions. The trick
    is to...
  10. Replies
    4
    Views
    776

    Re: Problems with MySql database

    I have never used QtSql, but the error message says:

    "An instance of QCoreApplication is required for loading plugins"

    You #include <QCoreApplication> , but never create an instance (object) of...
  11. Replies
    4
    Views
    776

    Re: Problems with MySql database

    1) As mentiond before, you should state what the error is.

    2) Shouldn't it be:



    qDebug() << "Opened!";
  12. Replies
    2
    Views
    824

    Re: hello world

    It should be


    int main() {
  13. Replies
    24
    Views
    2,487

    Re: Problem with maps

    And if you want to use find() it would be something like this:



    std::pair<const int,char> p(4,'b');

    it = find(m1.begin(),m1.end(),p);


    But this really does not make sense, since...
  14. Replies
    24
    Views
    2,487

    Re: Problem with maps

    1) find looks for equality of elements in the container. The elements are pairs, not a single char.

    2) you want find_if ... it starts to get more complicated using this.

    a) using find_if with a...
  15. Replies
    16
    Views
    1,341

    Re: Beginner problems with files

    I assume that by Qt you mean QtCreator. Visual C++ can take a std::string as as argument to fstream:open() ... most other compilers do not. If you are using QtCreator under Windows, it is probably...
  16. Replies
    16
    Views
    1,341

    Re: Beginner problems with files

    That is the open statement ... you forgot to add the .c_str() on one of them.
  17. Replies
    16
    Views
    1,341

    Re: Beginner problems with files

    I would guess that you have not posted the most up to date files.
  18. Replies
    16
    Views
    1,341

    Re: Beginner problems with files

    1) open takes a const char * as the first argument, not a std::string
    Convert using .c_str() member function of std::string



    ifsO1.open(pathIN.c_str(), ios_base::in);


    2) the prototype is:
  19. Replies
    4
    Views
    218

    Re: Slow regex issue (VS2010)

    The exception is being thrown at the construction of the regex object.




    Technically on the g++/MinGW system it is throwing an exception with code = std::regex_constants::error_brack
    There is...
  20. Replies
    4
    Views
    218

    Re: Slow regex issue (VS2010)

    1) I also ran under VC++ 2010. About 10 seconds debug and 2 seconds release

    2) Under g++ I get an exception thrown (see code for more details)

    3) My main is given below. The regexCode()...
  21. Replies
    5
    Views
    1,096

    Re: What is wrong with my code?

    1) Both classes absolutely need a Copy Constructor and and copy assignment operator

    2) Get Array1D debugged before trying to use it in Array2D

    3) Why does Array2D have this data member:


    ...
  22. Re: why the function itoa takes the signature as char * itoa ( int value, char * st

    Then itoa would need to create the buffer internally (since no buffer was past).
    Then the calling program would need to free the buffer. Generally, you don't
    want this type of scenario. Too much...
  23. Re: why the function itoa takes the signature as char * itoa ( int value, char * st

    Maybe it returns the string so that the result can be used directly ... example:



    cout << itoa(...);
  24. Re: What could cause a core dump at iterator pre increment??

    Scott Myers, Effective STL ... Item 9: Choose carefully among erasing options. I thought Josuttis had it in his book, but I can locate it at this time.

    Also, the method I posted is for...
  25. Re: What could cause a core dump at iterator pre increment??

    The problem is almost certainly the erasing ...

    The loop should have this form. Notice there is no "++iter" in the first line of the for loop.



    for ( MyMapT::iterator iter=inMap.begin();...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center