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

  • Home
  • SEARCH
  • 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 1063397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:46:43+00:00 2026-05-16T18:46:43+00:00

i have following code #include <iostream> #include <string> using namespace std; string generate(){ for

  • 0

i have following code

#include <iostream>
#include <string>
using namespace std;
string generate(){
     for (char c1='A';c1<='Z';c1++){
          for (char c2='A';c2 <='Z';c2++){
               for (char c3='A';c3<='Z';c3++){
                    for (char c4='A';c4<='Z';c4++){


                         return  (new string *)(c1) + (new string*)(c2)+(new string*)(c3)+(new string*)(c4);
                    }
               }
          }
     }


}
int main(){




     return 0;
}

i want to generate strings but here is error

1>------ Build started: Project: string_combinations, Configuration: Debug Win32 ------
1>Build started 9/11/2010 12:42:08 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\string_combinations.unsuccessfulbuild".
1>ClCompile:
1>  string_combinations.cpp
1>c:\users\david\documents\visual studio 2010\projects\string_combinations\string_combinations\string_combinations.cpp(11): error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\david\documents\visual studio 2010\projects\string_combinations\string_combinations\string_combinations.cpp(11): error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\david\documents\visual studio 2010\projects\string_combinations\string_combinations\string_combinations.cpp(11): error C2064: term does not evaluate to a function taking 1 arguments
1>c:\users\david\documents\visual studio 2010\projects\string_combinations\string_combinations\string_combinations.cpp(11): error C2064: term does not evaluate to a function taking 1 arguments
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.82
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

please help i am confused why i can’t directly convert from char to string by this method string(char)

  • 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-05-16T18:46:44+00:00Added an answer on May 16, 2026 at 6:46 pm

    The problem is with your expressions of this form:

    (new string *)(c1)
    

    The left hand side isn’t a type, it’s an expression. When you suffix it with another parenthesized expression it looks like a function call but that only works if the left expression is a function name or function pointer. In this case the new expression has type std::string** which isn’t a function pointer.

    To construct a temporary string from a single char, you shouldn’t use new which dynamically allocates an object; instead you can use a constructor. A suitable one is the one which takes a count and a char to repeat for that count. In your case a count of 1 is what you want:

    std::string(1, c1);
    

    You can do something like.

    return std::string(1, c1) + std::string(1, c2);
    

    Note that you also don’t call generate anywhere and if you do return from the first iteration of a for loop you aren’t going to be iterating through all the combinations, you will only every generate the first compination.

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

Sidebar

Related Questions

i have following code #include <iostream> using namespace std; int main(){ int i; char
I have following code #include <iostream> #include <string> #include <algorithm> using namespace std; int
I have the following code: main.cpp #include <iostream> #include <string> using namespace std; string
I have the following code: #include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc
I have the following code #include <iostream> #include<string> #include <sstream> using namespace std; struct
i have following code in c++ #include <iostream> using namespace std; void qsort5(int a[],int
I have a the following code: #include <iostream> using namespace std; void func(char *
i have following code #include <iostream> #include <set> #include <string> using namespace std; template<class
I have the following code: #include <iostream> #include <string> #include <unistd.h> using namespace std;
I have the following C++ code: #include <iostream> #include <string> using namespace std; class

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.