Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8959697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:29:59+00:00 2026-06-15T15:29:59+00:00

my code are as follows ,path1.updatePathInfo() is an function which call an empty function,if

  • 0

my code are as follows ,path1.updatePathInfo() is an function which call an empty function,if delete this it will works fine.I could’t understand.

////////////////////////////////////////////////////main.cpp

#include <iostream>
#include<vector>
#include "CPath.h"
using namespace std;
int main()
{
    for(int i = 0;i<10;++i)
    {
        cout<<i;
        CPath path1;
        CPath path2;
        cross(path1,path2);
        path1.updatePathInfo();  //this is an function which call an empty function
                                 //if I delete this it works fine.I could't understand.
        path2.updatePathInfo();

    }
}

//////////////////////////////////////////////////////////////CPath.h

#ifndef CPATH_H_
#define CPATH_H_
#include<iostream>
#include<vector>
#include<fstream>
#include<map>
#include<cmath>
#include<cstdlib>
class CPath
{
public:
    CPath();
    friend void cross(CPath & path1,CPath & path2);
    void updatePathInfo();
    std::vector< int > getPathByCode();
    void createRadomCode();
    std::vector< int > code;
    double pathLineLength;
};
#endif //CPATH_H_

//////////////////////////////////////////////////////////////////////CPath.cpp

#include"CPath.h"
CPath::CPath()
{
    createRadomCode();
}

void cross(CPath & path1,CPath & path2)
{
    int max,min;
    max = rand()%8;
    min = rand()%8;
    if(min > max)
    {
        max ^= min;min ^= max;max ^= min;
    }
    if(0.9*100>rand()%100)
    {
        for(int i = min;i<=max;++i)
        {
            path1.code[i]^=path2.code[i];
            path2.code[i]^=path1.code[i];
            path1.code[i]^=path2.code[i];
        }
    }
}

void CPath::updatePathInfo()
{
    getPathByCode();
}

std::vector< int > CPath::getPathByCode()
{
    //this function has nothing 
}

void CPath::createRadomCode()
{
    for(int i = 0 ; i<8 ; ++i)
    {
        code.push_back(rand()%(i+1));
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:30:00+00:00Added an answer on June 15, 2026 at 3:30 pm

    CPath::getPathByCode() does not return a value and the result is undefined behaviour. Your compiler is not required to tell you about this, but if you compile with all warnings enabled it almost certainly will.

    As an aside, if you formatted your code correctly, this sort of error would be much easier to see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build some client side code which follows this use case: An
Why can't I do something like this in c# (pseudo code follows) Interface1 {
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
I have the controller code as follows: $form_company=new Project_Form_AddCompany(); $this->view->form=$form_company; $form_company->setAction('add-Company'); if ($this->_request->isPost()) {
I am using the library ICSharpCode.SharpZipLib.Zip ; My code is follows: The path is
For some code as follows, opts, args = getopt.getopt(sys.argv[1:], c:, ... for o,v in
I have a piece of javascript code as follows: var data = { ...
I'm setting the timeout value of an NSMutableURLRequest in code as follows: request.timeoutInterval =
Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.