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

Search:

Type: Posts; User: dwhitney67

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    1,720

    Re: why cout doesn't print my string?

    Let's start by cleaning up the code, and more importantly placing it within CODE tags so that it is easier to read.

    First, avoid using char arrays in C++; instead use the STL string container...
  2. Replies
    2
    Views
    718

    Re: select() on a socket

    hoxsiew, you are correct; the fd_set (and the timeout period, if used) needs to be (re)set before each call to the select().

    I found the problem to the issue I was having. The code, which I...
  3. Replies
    2
    Views
    718

    select() on a socket

    I am having an issue with an overzealous select() call. I works as expected until I send a single UDP message to my socket. Then it reports that there is activity even after the application...
  4. Replies
    15
    Views
    1,081

    Re: unresolved externals with templates

    I think you are misunderstanding the fundamentals that have been presented thus far in this thread.

    The simplest approach to the issue you are having is to place the implementation of the template...
  5. Replies
    15
    Views
    1,081

    Re: unresolved externals with templates

    That's pretty nifty.


    I'll concede to that argument.


    I first saw the .impl extension being used when I dabbled with CORBA programming a few years ago.
  6. Replies
    15
    Views
    1,081

    Re: unresolved externals with templates

    I agree with what you have stated, but why would one do this unless they are short of RAM? The whole point of creating a template is to provide reusable code that can work with any object, those...
  7. Replies
    3
    Views
    917

    Re: UDP server strange behaviour

    Try augmenting the size of your server's socket receiving buffer. Here's how with Linux C++; I do not know how well this translates to VC++.



    const int size = 1470 * 100; // 1470 bytes * 100...
  8. Replies
    15
    Views
    1,081

    Re: unresolved externals with templates

    The implementation of templated code MUST be within (or included within) the header file.



    // header.h
    #pragma once

    template <class T>
    class base
    {
  9. Replies
    13
    Views
    3,235

    Re: Including a class within another class

    Most s/w development projects have standards that differ from your opinion. But at the end of the day, do whatever pleases you (and your peers). Don't cry though when someday you have to maintain a...
  10. Replies
    13
    Views
    3,235

    Re: Including a class within another class

    Hopefully you will see this post; below is the minimum to get you on your way...

    Location.h:


    #ifndef LOCATION_H
    #define LOCATION_H

    #include "Enemy.h"
    #include <vector>
  11. Replies
    13
    Views
    3,235

    Re: Including a class within another class

    One of the keywords, or noun, in your statement is 'game'. You should have a class object that represents the Game, and it is within there, that you would declare your Player object(s), game-board,...
  12. Replies
    13
    Views
    3,235

    Re: Including a class within another class

    Never place a "using namespace" directive in a header file; it is considered poor programming practice.

    Additionally, it would be better to define an enum or another type (e.g. static const...
  13. Re: Confused by exceptions thrown by iostream classes

    There is not much information provided by the fstream exception, other than an error occurred when attempting to open or read from the file. Generally speaking, there really is no difference between...
  14. Replies
    3
    Views
    1,267

    Re: Error with function call.

    This issue lies with the declarations of your functions. You really want to pass all of your parameters by reference, not by value. The error that you are getting is caused by your attempt to copy...
  15. Re: Problem with setting filename using a string...

    I also don't see the purpose of using fopen() when C++ provides the fstream (or more specifically, ofstream) class.



    #include <fstream>

    int main()
    {
    ...
    std::cout << "Enter filename:...
  16. Replies
    1
    Views
    396

    Re: simple input problem

    I find this hard to believe! The following code works fine:


    #include <fstream>
    #include <string>
    #include <iostream>

    int main()
    {
    std::fstream file("data.dat", std::ios::in);
  17. Replies
    1
    Views
    2,916

    Re: Convert ctime() string to tm struct?

    The use of ctime() requires a time_t parameter. Why do you not use that same time_t parameter in either gmtime() or localtime() to yield the struct tm?

    If that is not an option, then just use...
  18. Re: Should be the last time I bother everyone.

    Would it not be helpful to have one of these statements inside that new while-loop you added:


    getline(inData, s);
  19. Re: Should be the last time I bother everyone.

    Have you tried outputting the string 's' to the screen using std::cout?



    ...
    int line = 0;
    while (!inData.eof())
    {
    ...
    if...
  20. Re: error 10022 on passing timeval to select

    Actually, your usage of the struct timeval is correct. It is quite possible it is one of the other parameters is causing the error.

    I normally do not perform the static_cast<int> as you have...
  21. Replies
    3
    Views
    506

    Re: reading input between 1 and 100

    I figured this was for a class, and thus I provided a semi-advanced example. Take the code I wrote, an in lieu of the vector, pass the array as you had done. Within the choiceRead() function,...
  22. Replies
    1
    Views
    359

    Re: beginner help with switch and path

    Initially when you prompt the user for a choice between encoding and decoding, only the numeric input is processed and stored in nSel. The newline character is still sitting in the cin stream, and...
  23. Replies
    3
    Views
    506

    Re: reading input between 1 and 100

    You are writing code in C++. You should avoid using a C-style array for storing values; use an std::vector instead. You do not need to keep track of its size, and thus is safer to use (there is no...
  24. Replies
    8
    Views
    605

    Re: Number generator between 0-100

    How about this:


    int probability(const int low, const int high)
    {
    int p;

    do
    {
    p = rand() &#37; (high + 1);
  25. Re: To expert developers: help to evolve in development

    Get this book and read it.
    http://www.amazon.com/Effective-Specific-Addison-Wesley-Professional-Computing/dp/0201924889

    It's a starting point!
Results 1 to 25 of 56
Page 1 of 3 1 2 3


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center