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 8874125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:38:28+00:00 2026-06-14T18:38:28+00:00

Alright so heres the program and works absolutely right #include <iostream> using namespace std;

  • 0

Alright so heres the program and works absolutely right

#include <iostream>

using namespace std;

template <typename T>
void Swap(T &a , T &b);

int main(){

    int i = 10;
    int j = 20;

    cout<<"i, j = " << i <<" , " <<j<<endl;
    Swap(i,j);
    cout<<"i, j = " << i <<" , " <<j<<endl;


}
template <typename T>
void Swap(T &a , T &b){
    T temp;
    temp = a ;
    a = b;
    b= temp;
}

but when I change the function’s name from Swap to swap
it generates an error saying

error: call of overloaded ‘swap(int&, int&)’ is ambiguous| note:
candidates are: void swap(T&, T&) [with T = int]| ||=== Build
finished: 1 errors, 0 warnings ===|

what happened is it a rule to start functions using templates to start with a capital letter ?

  • 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-14T18:38:29+00:00Added an answer on June 14, 2026 at 6:38 pm

    This is because there already exists a function called swap. It is actually under the std namespace, but because you have a using namespace std line, it exists without the std:: prefix.

    As you can see, using the using namespace std isn’t always a good option because of possible name collisions, as in this example. In general one should prefer not to use the using directive unless there’s a real reason for this – namespaces exist for a reason – to prevent name collisions.

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

Sidebar

Related Questions

Alright so I am making a simple Tic Tac Toe program. Right now I
Alright, Heres the thing. I have a (paid for) shopping cart, which I am
Alright...I am here looking for some bread crumbs. This is my code: using System;
Alright, so heres my problem: I have an application I am working with that
Alright, I'm trying to set a program I have to receive data from a
Alright, so heres my problem, i need my user to be able to upload
Alright heres the deal. I have a sports app that i want to update
I'm really confused with the program flow for how the paintComponent function works within
Alright guys, so Im using rapidXML to parse a very simple XML document. All
I'm adding some code into a using block in a C# program. I'm sort

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.